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