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