Unable so assign value to .Lookin Property
Hi Everyone,
My first post on here... I've tried asking this question in a forum on another website but no one managed to suggest a solution.
Excel 2003 VBA
I've taken a simple procedure from the VBA helpfiles but I can't seem to get it to work properly.
Code:
Sub foo()
Dim fs As FileSearch, i As Integer
Set fs = Application.FileSearch
With fs
.LookIn = "U:\Calls"
.Filename = "Tass*"
Debug.Print .LookIn
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
Set fs = Nothing
End Sub
I wondered why it could not find any files so I added the Debug.Print .LookIn line and this informs me that the value of the lookin property is "C:\My Documents".
There are other workarounds (filesystemobject) which will allow me to achieve what I need to, but I am frustrated that this does not work!! Are there any settings I need to be aware of which determine whether or not you can assign a value to this property?
Thanks in advance for your help.
|