File Search...

Home Search Site Map

Up
Close
Exit
File Search...
Most Frequently Used
New...
Open...
Page Setup...
Permission
Print...
Print Area
Print Preview
Properties
Save
Save As...
Save as Web Page...
Save Workspace...
Send To
Web Page Preview

New! Excel User Group Now Open @ www.excelusergroup.org, Check It Out!


Menu command Type What happens next?
File Search... ... Allows windows file search functionality within the Excel application. Below is the search 'Task Pane' launched by this command.

VBA Sub UseFileSearch()
'Searches for xls files in a location and lists on a new sheet
Dim fs As FileSearch
Dim ff As FoundFiles
Dim wks As Worksheet
Dim x As Long
Set fs = Application.FileSearch
Set ff = Application.FileSearch.FoundFiles
Set wks = Worksheets.Add
wks.Name = "Files"
With fs
.LookIn = "C:\Documents and Settings\Nick Hodge\My Documents\Excel"
.FileType = msoFileTypeExcelWorkbooks
.Execute AlwaysAccurate:=True
End With
For x = 1 To ff.Count
wks.Cells(x, 1).Value = ff.Item(x)
Next x
wks.Columns("A:A").AutoFit
Set ff = Nothing
Set fs = Nothing
End Sub

Copyright Nick Hodge 2008. All Rights Reserved.