Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search Directories/SubDirectories UserForm
Would anyone know how to create a userform that searches all subdirectories
for a particular name (ex: Any file with R0012 in it's name) and list the findings within the form itself? Another example, if I used the search function on Windows (start, search, find...), the results should be within the userform with a scroll bar to show all. Any help anyone can give will be greatly appreciated. -- PK |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search Directories/SubDirectories UserForm
Hi Patrick
The code below is pretty much the code stright from the excel VBA help file. To test it create a userform with a listbox and a button and paste the code below to userform module. Option Explicit Dim Fs As Object Dim i As Integer Private Sub CommandButton1_Click() Set Fs = Application.FileSearch With Fs 'Change below to give the name of the Directory you want to search .LookIn = "C:\" .SearchSubFolders = True .Filename = "*R0012*" If .Execute() 0 Then For i = 1 To .FoundFiles.Count ListBox1.AddItem (.FoundFiles(i)) Next i Else MsgBox "There were no files found." End If End With End Sub Hope this helps Steve |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search Directories/SubDirectories UserForm
Incidental, thank you. It works great!
-- PK "Incidental" wrote: Hi Patrick The code below is pretty much the code stright from the excel VBA help file. To test it create a userform with a listbox and a button and paste the code below to userform module. Option Explicit Dim Fs As Object Dim i As Integer Private Sub CommandButton1_Click() Set Fs = Application.FileSearch With Fs 'Change below to give the name of the Directory you want to search .LookIn = "C:\" .SearchSubFolders = True .Filename = "*R0012*" If .Execute() 0 Then For i = 1 To .FoundFiles.Count ListBox1.AddItem (.FoundFiles(i)) Next i Else MsgBox "There were no files found." End If End With End Sub Hope this helps Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Getting names of files in subdirectories | Excel Programming | |||
All Subdirectories | Excel Programming | |||
Search all directories for .mdb files | Excel Programming | |||
Search text in multiple files in multiple directories | Excel Programming | |||
Subdirectories | Excel Programming |