Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lookin property of the FileSearch object | New Users to Excel | |||
csv for filetype property of filesearch object | Excel Programming | |||
Cannot assign value to Filesearch.Lookin | Excel Programming | |||
Lookin Property. | Excel Programming | |||
FileSearch Problem | Excel Programming |