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

I am having problems with this bit

Status
Not open for further replies.

andrew299

Technical User
Nov 18, 2002
140
GB
I am having problems with this bit of code
It searchs for all files of a particular name, modified on a particular day. There should be only one. It then displays the location in a message box. The trouble is it will display the location in the box but I cannot use it later in my program which is the whole point of the search.

Sub filefind()

Dim extract$

Set fs = Application.FileSearch
fs.NewSearch
With fs.PropertyTests

.Add Name:="Last Modified", _
Condition:=msoConditionAnytimeBetween, _
Value:="09/12/02", SecondValue:="09/12/02", _
Connector:=msoConnectorAnd
End With


With fs
.LookIn = "C:\"
.SearchSubFolders = True
.MatchTextExactly = True
.Filename = "extract.exe"
.MatchTextExactly = True

If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
i = 1
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)

Next i

Else
MsgBox "The file was not found"

End If

extract$ = .FoundFiles(i).Item xxxxxxxxxxxxxxxxxxxxxxx

End With

The problem is at the line highlighted above I want extract$ to contain the location information.

Andrew299

:0

 
change this snippet to:

For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
myFoundFile = FoundFiles(i)
Next i
Then use myFoundFile to reference the file Rgds
~Geoff~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top