I am trying to create a list of image files jpg and gif from 1 directory on the HD. I have the code to return one file using FOUNDFILE. The FILENAME property can be set to "*.jpg" to find jpgs and "*.gif" to find gifs. However I cant combine the two.
Is there another way to do this?
Code:
-----
' locate the files
Set fs = Application.FileSearch
With fs
.LookIn = "C:\work"
<b>.FileName = "*.jpg"<\b>
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
Is there another way to do this?
Code:
-----
' locate the files
Set fs = Application.FileSearch
With fs
.LookIn = "C:\work"
<b>.FileName = "*.jpg"<\b>
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With