Sub DoDir()
' Display the names in C:\ that represent directories.
myPath = "c:\" ' Set the path.
MyName = Dir(myPath, vbDirectory) ' Retrieve the first entry.
DirCount = 0
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If InStr(1, MyName, ".sys" = 0 Then
theAttrib = GetAttr(myPath & MyName)
If (theAttrib And vbDirectory) = vbDirectory Then
ActiveCell.Offset(DirCount).Value = myPath & MyName
DirCount = DirCount + 1
End If ' it represents a directory.
End If
End If
MyName = Dir ' Get next entry.
Loop
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.