"." and ".." are standard DOS folder 'shortcuts'. Type in DIR in a command window and you will see them. "." is the current directory and ".." is the parent directory. In VBA, use an If statement to ignore them and GetAttr to check if the file returned by Dir is a directory:
Sub List_Subfolders()
Dim folder As String
Dim fileName As String
folder = "C:\Windows\"
If Right(folder, 1) <> "\" Then folder = folder & "\"
fileName = Dir(folder, vbDirectory)
Do While fileName <> ""
If fileName <> "." And fileName <> ".." Then
'Make sure it's a directory
If (GetAttr(folder & fileName) And vbDirectory) = vbDirectory Then
MsgBox folder & fileName
End If
End If
fileName = Dir
Loop
End Sub
Bookmarks