sub directories again
Unfortunately The VBA code didn't work...because there was a small command
error with this line:
If UCase(Right(MyName), 4) = UCase(MyCond) Then
I think we are not allowed to use anything else then just a string within
the "( )" for the UCase( xxxxxx) command.
Thus I changed your code a bit and now it works just fine...
Here goes:
--------------------------------
Sub ListFileName()
Dim filearray()
Dim MyPath, MyName, Mt, MyCond ' I declare an additional variable called
Mt
Dim j As Long, a As Long
MyPath = "c:\windows\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrive the first entry.
MyCond = ".txt"
Do While MyName < "" ' Start the loop.
If (GetAttr(MyPath & MyName) And vbDirectory) < vbDirectory Then
Mt = (Right(MyName, 4)) ' I use this new variable to get the last
four characters.
If UCase(Mt) = UCase(MyCond) Then ' And changed this bit such that
the format of UCase is accepted.
a = a + 1
ReDim Preserve filearray(a)
filearray(a) = MyName
End If
End If
MyName = Dir ' Get next entry.
Loop
Open "c:\filearray.txt" For Output As #1
For j = 1 To a
Write #1, filearray(j)
Next
Close #1
End Sub
---------------------------------------
Thanks a lot for your help.
Sincerely
|