first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Code: Scanning A Root for Files and Directories

Public Function basScan() As Boolean

Dim strPath As String, strName As String

On Error GoTo basScan_Err

basScan = True    

strPath = "C:\\"

strName = VBA.Dir(strPath, vbDirectory)

Do While strName <> Empty
    'Ignore file system directories.
    If strName <> "." And strName <> ".." Then
        ' Use bitwise comparison to make sure strName is a directory.
        If (VBA.GetAttr(strPath & strName) And vbDirectory) > 0 Then
            Debug.Print "Directory: " & strName
        ' Use bitwise comparison to make sure strName is a file.
        ElseIf (VBA.GetAttr(strPath & strName) And vbDirectory) = 0 Then
            Debug.Print "File: " & strName
        End If
    End If
    ' Get next entry for current path.
    strName = VBA.Dir
Loop

basScan_Exit: Exit Function

basScan_Err: Select Case VBA.Err Case Else VBA.MsgBox VBA.Err & ": " & VBA.Err.Description, _
vbCritical, "basScan Error" basScan = False Resume basScan_Exit End Select End Function

mod date: 1998-12-01T02:36:08.000Z