R
Ray
I am attempting to run this code from the help file example for Dir
' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
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 (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop
Howerver this line
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
lookes like it is supposed to determine if the file name received is a
Directory or not
I does not identify directories as directories. It acctually skips them and
just gets file names.
then when I attempt this bit of code
' Now recursively iterate through each cached subdirectory.
For I = 1 To Count
List1.AddItem Path & D(I) ' Put name in list box.
ListSubDirs Path & D(I) & "\"
Next I
It appends the backslash to a file name and attempts to use it as a folder
name.
Then it errors and says invalid file name
Now this is out of the VBA Word help file.
I know help files are always correct.
Can you show me what I have done wrong on this?
Thanks
' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
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 (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop
Howerver this line
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
lookes like it is supposed to determine if the file name received is a
Directory or not
I does not identify directories as directories. It acctually skips them and
just gets file names.
then when I attempt this bit of code
' Now recursively iterate through each cached subdirectory.
For I = 1 To Count
List1.AddItem Path & D(I) ' Put name in list box.
ListSubDirs Path & D(I) & "\"
Next I
It appends the backslash to a file name and attempts to use it as a folder
name.
Then it errors and says invalid file name
Now this is out of the VBA Word help file.
I know help files are always correct.
Can you show me what I have done wrong on this?
Thanks