Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a combobox list of images in Word VBA Form

Status
Not open for further replies.

mdav2

Programmer
Aug 22, 2000
363
GB
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 = &quot;*.jpg&quot;<\b>
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox &quot;There were &quot; & .FoundFiles.Count & _
&quot; file(s) found.&quot;
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox &quot;There were no files found.&quot;
End If
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top