Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Help with Application.FileSearch method

I copied the code below right out of Excel VBA Help, changing only the
folder specified in ".Lookin" to "C:\Tsfr". I know this folder exists on my
computer and contains three .doc files. Therefore the code should report
three files found, but instead it erroneously reports no files found. Any
suggestions as to what's going on would be appreciated. Thanks.

Sub Filetest()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Tsfr"
.Filename = "*.doc"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For Counter = 1 To .FoundFiles.Count
MsgBox .FoundFiles(Counter)
Next Counter
Else
MsgBox "There were no files found."
End If
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Help with Application.FileSearch method

Hi roy

Try it with

.LookIn = "C:\Tsfr\"
.Filename = ".doc"



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Roy Harrill" wrote in message ...
I copied the code below right out of Excel VBA Help, changing only the folder specified in ".Lookin" to "C:\Tsfr". I know this
folder exists on my computer and contains three .doc files. Therefore the code should report three files found, but instead it
erroneously reports no files found. Any suggestions as to what's going on would be appreciated. Thanks.

Sub Filetest()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Tsfr"
.Filename = "*.doc"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For Counter = 1 To .FoundFiles.Count
MsgBox .FoundFiles(Counter)
Next Counter
Else
MsgBox "There were no files found."
End If
End With
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Help with Application.FileSearch method

Ron,
Thanks for the reply. I tried that, but unfortunately got the same result.
BTW, I'm running Windows XP Pro SP2 and Excel 2003.
Roy


"Ron de Bruin" wrote in message
...
Hi roy

Try it with

.LookIn = "C:\Tsfr\"
.Filename = ".doc"

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Roy Harrill" wrote in message
...
I copied the code below right out of Excel VBA Help, changing only the
folder specified in ".Lookin" to "C:\Tsfr". I know this folder exists on
my computer and contains three .doc files. Therefore the code should
report three files found, but instead it erroneously reports no files
found. Any suggestions as to what's going on would be appreciated.
Thanks.

Sub Filetest()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Tsfr"
.Filename = "*.doc"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For Counter = 1 To .FoundFiles.Count
MsgBox .FoundFiles(Counter)
Next Counter
Else
MsgBox "There were no files found."
End If
End With
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Help with Application.FileSearch method

Hi Roy

There are more problems with FileSearch.
Use Dir instead or fill a array with file names

Maybe you can steal some code from this page.
http://www.rondebruin.nl/copy3.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Roy Harrill" wrote in message ...
Ron,
Thanks for the reply. I tried that, but unfortunately got the same result.
BTW, I'm running Windows XP Pro SP2 and Excel 2003.
Roy


"Ron de Bruin" wrote in message ...
Hi roy

Try it with

.LookIn = "C:\Tsfr\"
.Filename = ".doc"

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Roy Harrill" wrote in message ...
I copied the code below right out of Excel VBA Help, changing only the folder specified in ".Lookin" to "C:\Tsfr". I know this
folder exists on my computer and contains three .doc files. Therefore the code should report three files found, but instead it
erroneously reports no files found. Any suggestions as to what's going on would be appreciated. Thanks.

Sub Filetest()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Tsfr"
.Filename = "*.doc"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For Counter = 1 To .FoundFiles.Count
MsgBox .FoundFiles(Counter)
Next Counter
Else
MsgBox "There were no files found."
End If
End With
End Sub







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Help with Application.FileSearch method

Thanks again, Ron. I changed to using a Dir approach and everything works
fine. Looks like ole MS needs to do a little work on FileSearch. Do I look
surprised?
Roy

"Ron de Bruin" wrote in message
...
Hi Roy

There are more problems with FileSearch.
Use Dir instead or fill a array with file names

Maybe you can steal some code from this page.
http://www.rondebruin.nl/copy3.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl

"Roy Harrill" wrote in message
...
Ron,
Thanks for the reply. I tried that, but unfortunately got the same result.
BTW, I'm running Windows XP Pro SP2 and Excel 2003.
Roy

"Ron de Bruin" wrote in message
...
Hi roy

Try it with:
.LookIn = "C:\Tsfr\"
.Filename = ".doc"

--
Regards Ron de Bruin
http://www.rondebruin.nl

"Roy Harrill" wrote in message
...
I copied the code below right out of Excel VBA Help, changing only the
folder specified in ".Lookin" to "C:\Tsfr". I know this folder exists on my
computer and contains three .doc files. Therefore the code should report
three files found, but instead it erroneously reports no files found. Any
suggestions as to what's going on would be appreciated. Thanks.

Sub Filetest()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Tsfr"
.Filename = "*.doc"
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
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.FileSearch Cleberton(Brazilian) Excel Discussion (Misc queries) 2 October 26th 09 01:21 PM
Application.FileSearch crashed Excel in Windows 2K Ken Loomis Excel Programming 0 July 14th 05 01:04 AM
Application.FileSearch is not working?? alondon Excel Programming 5 January 18th 05 03:12 AM
Application.Filesearch yields incorrect results?? Ed[_23_] Excel Programming 2 August 24th 04 08:59 PM
VBA Application.FileSearch Roger Frye Excel Programming 0 March 5th 04 04:07 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"