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
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