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: 40
Default Search Directories/SubDirectories and Display in ListBox or MsgBox

I have modified the code below from a reply to a question in 2007 from
Patrick Kirk. I am using MS Office Excel 2003.

For my use I would prefer the results within 2 possible scenarios;

1) a ListBox so that I may choose just see or select a file that was found
and proceed to work with it, such as open an XLS, if the file is an XLS file.
2) a MsgBox, but each file found must be displayed on separate lines within
the MsgBox

The difference for me too is that this IS NOT for a user form but rather a
macro that can be assigned to a button.

Suggestions?


Sub findFile()
Dim showThis As String
Dim i As Integer

Set Fs = Application.FileSearch
With Fs
'Change below to give the name of the Directory you want to search
.LookIn = "C:\Fun Stuff\Excel\"
.SearchSubFolders = True
.Filename = "msgbox"
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
showThis = showThis & " " & .FoundFiles(i)
'ListBox1.AddItem (.FoundFiles(i))
Next i
MsgBox .FoundFiles.Count & showThis
Else
MsgBox "No files found."
End If
End With
End Sub
 
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
List Directories and Subdirectories Steven Excel Programming 2 April 22nd 08 02:11 AM
search column and display results in msgbox mike Excel Programming 1 January 23rd 08 03:18 AM
Search Directories/SubDirectories UserForm Patrick Kirk Excel Programming 2 December 23rd 07 02:25 PM
Search all directories for .mdb files Sue Excel Programming 0 July 3rd 07 06:58 PM
VBA code to search and display results in multicolumn listbox [email protected] Excel Programming 6 February 7th 07 01:32 AM


All times are GMT +1. The time now is 11: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"