Problem with setting a R / W property, FileSearch, LookIn

C

chuckd

I'm using typical FileSearch code in Excel to build a list of files and write
to the cells of a worksheet. In teh code shown below: date_txt is decalred
Public and dir is a local and are read from a worksheet.

The code runs fine on some computers but has a problem on others. The
problem is .LookIn can not be set to the value in dir. Using the Immediate
command window in debug doesn't allow setting .LookIn either.

Trying to set .LookIn has the symptoms of acting like .LookIn is not a write
property, does not issue any error, and leaves .LookIn with the default value
it is created with.

Running the code always returns 0 files when running on the problem computer.

Code follows.

Thanks,
chuckd

With Application.FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = dir
.SearchSubFolders = True
.FileType = msoFileTypeAllFiles
.Filename = date_txt
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
report_macros_workbook.Worksheets("files").Cells(i + 1,
3).Value = .FoundFiles(i)
Next i
Else
' MsgBox " there are no file found."

End If
End With
End With
 
B

Bob Phillips

I haven't reproduced the problem, but is this line getting in the way

With Application.FileSearch


I would delete it and its corresponding End With

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top