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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to perform a "VBA FileSearch method" like in VB6???

Status
Not open for further replies.

2781

Technical User
Feb 26, 2002
21
BE
Hi,

In VBA, it is relatively simple to look through all the files in a folder, and open all the *.doc files consecutively. How do you perform the same operation in Visual Basic 6, instead of in Visual Basic for Applications.

THanks

MS gives the following example in VBA it looks:

Set fs = Application.FileSearch
With fs
.LookIn = "A:"
.FileName = "*.doc"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then

For i = 1 To .FoundFiles.Count
MyDoc = .FoundFiles(i)
Documents.Open FileName:=MyDoc, ReadOnly:=True
' Do your thing ....

Documents(MyDoc).Close SaveChanges:=wdDoNotSaveChanges
Next i
Else
MsgBox "There were no files found."
End If

End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top