ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with setting a R / W property, FileSearch, LookIn (https://www.excelbanter.com/excel-programming/377114-problem-setting-r-w-property-filesearch-lookin.html)

chuckd

Problem with setting a R / W property, FileSearch, LookIn
 
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

Bob Phillips

Problem with setting a R / W property, FileSearch, LookIn
 
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)

"chuckd" wrote in message
...
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




chuckd

Problem with setting a R / W property, FileSearch, LookIn
 
Thanks for the suggestion. The change didn't help
chuckd

"Bob Phillips" wrote:

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)

"chuckd" wrote in message
...
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






All times are GMT +1. The time now is 04:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com