#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Find Files

Hello,
I am using the following code to find a file on the C drive. The file is
there, but the code keeps saying no file was found. Any help? Thanks.

Sub test()

Set fs = Application.FileSearch
With fs
.LookIn = "C"
.Filename = "Fname.xls"
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Find Files

Bill,

Your code worked for me when I declared the two variables
and corrected the directory designation...
'-----------------
Dim fs
Dim i As Long
Set fs = Application.FileSearch
With fs
.LookIn = "C:\"
'---------------------

Jim Cone
San Francisco, USA


"Bill" wrote in message
ink.net...
Hello,
I am using the following code to find a file on the C drive. The file is
there, but the code keeps saying no file was found. Any help? Thanks.

Sub test()
Set fs = Application.FileSearch
With fs
.LookIn = "C"
.Filename = "Fname.xls"
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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Find Files

Thanks. That worked.


"Jim Cone" wrote in message
...
Bill,

Your code worked for me when I declared the two variables
and corrected the directory designation...
'-----------------
Dim fs
Dim i As Long
Set fs = Application.FileSearch
With fs
.LookIn = "C:\"
'---------------------

Jim Cone
San Francisco, USA


"Bill" wrote in message
ink.net...
Hello,
I am using the following code to find a file on the C drive. The file is
there, but the code keeps saying no file was found. Any help? Thanks.

Sub test()
Set fs = Application.FileSearch
With fs
.LookIn = "C"
.Filename = "Fname.xls"
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
find dependent files Vixstar Excel Discussion (Misc queries) 1 October 4th 10 08:53 AM
Where is "open/tools/find/find files that match these criteria"? PJ Excel Discussion (Misc queries) 2 November 14th 08 04:11 PM
Excel can't find files bscra Excel Discussion (Misc queries) 2 October 21st 07 12:14 AM
FileSearch doesn't find zip files Hub van de Laar Excel Programming 3 September 1st 03 07:43 PM
Import multiple files macro can't find files Steven Rosenberg Excel Programming 1 August 7th 03 01:47 AM


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

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

About Us

"It's about Microsoft Excel"