T
Tony Logan
I'm trying to find a way to gather a list of all files of a certain type in a
folder. For example, let's say folder "Work" has three .doc files and two
..txt files. I'd like to be able to gather a list of only the .doc files.
Can the code below, which was copied from Word's Visual Basic Help
files(under "Files Collection"), be modified to do what I want? And what is
"folderspec"?
Here's the code:
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & vbCrLf
Next
MsgBox s
End Sub
I wrote an additional macro to call the above subroutine:
Sub Call_File_List()
Call ShowFolderList("C:\Data\Edgar PPT\4Q03\")
End Sub
Thanks.
folder. For example, let's say folder "Work" has three .doc files and two
..txt files. I'd like to be able to gather a list of only the .doc files.
Can the code below, which was copied from Word's Visual Basic Help
files(under "Files Collection"), be modified to do what I want? And what is
"folderspec"?
Here's the code:
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & vbCrLf
Next
MsgBox s
End Sub
I wrote an additional macro to call the above subroutine:
Sub Call_File_List()
Call ShowFolderList("C:\Data\Edgar PPT\4Q03\")
End Sub
Thanks.