LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default file search with excel vba

I can do a file search using the following code:
Sub findfiles()


Application.MoveAfterReturnDirection = xlDown
Application.MoveAfterReturn = True


Set fs = Application.FileSearch
With fs
.NewSearch
.LookIn = "c:\"
.SearchSubFolders = True
.MatchTextExactly = False
.filename = "dssi expense.xlt"
If .Execute(msoSortByNone, msoSortOrderAscending,
True) 0 Then

'counts the files in list and stores the value in
total count
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
totalcount = .FoundFiles.Count

'for each file found, write the path and file to a
cell.
For i = 1 To .FoundFiles.Count
Worksheets("sheet1").Cells(i, 1).Value
= .FoundFiles(i)
Next i


Else
MsgBox "There were no files found."
End If
End With

End Sub

The code is more or less borrowed from the various
samples. The problem is that the search finds all
templates using *.xlt, but it will not find specific
templates such as 'dssi expense report.xlt'. It will find
other specific templates, but not the one mentioned
above. If i create a new template, it will not find that
template, using a specific search. If i copy and paste
and existing template, that it has found before, it wont'
find the copy.

I have tried lots of test, but nothing is working. Any
ideas?

RobertW

 
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
Excel File search function Mark Excel Discussion (Misc queries) 0 May 12th 10 09:49 PM
File Search Excel 2003 shaz Excel Discussion (Misc queries) 1 February 18th 10 11:44 AM
how do you search for a file in Excel 07? btc4 Excel Discussion (Misc queries) 1 December 17th 09 06:39 PM
How to search for a value in a column in another Excel file MSSailor Excel Discussion (Misc queries) 6 March 9th 09 05:01 PM
How to use one excel file to search another? [email protected] Excel Discussion (Misc queries) 0 June 21st 06 09:51 PM


All times are GMT +1. The time now is 07:15 PM.

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"