Wild Card Search Excel 2003

A

akrashid

Hi All,

I am using the following function to search a folder and display all
of its PDF files as hyperlinks using the following module. I would now
like to change it where it could prompt a user for input say a name
segment of a file. If a file is say Bright Works they coud enter
*right and the module would search the folders & sub-folders and
display the PDF for Bright Works .

Thanks in advance for all your help,here is the module:


Sub Prior_Turbine_A()
Dim i As Long
With Application.FileSearch
.NewSearch
.SearchSubFolders = True
.Filename = "*.pdf"
.LookIn = "I:\Prior_Turbine_A"
.Execute
For i = 1 To .FoundFiles.Count
ActiveSheet.Hyperlinks.Add Anchor:=Range("A" & i), _
Address:=.FoundFiles(i), TextToDisplay:= _
Right(.FoundFiles(i), Len(.FoundFiles(i)) - _
InStrRev(.FoundFiles(i), "\"))
Next
End With
End Sub
 
V

Vergel Adriano

try something like this:

Sub Prior_Turbine_A()
Dim i As Long
Dim strSearch As String

strSearch = InputBox("Enter search string")

With Application.FileSearch
.NewSearch
.SearchSubFolders = True
.FileType = msoFileTypeAllFiles
.Filename = "*" & strSearch & "*.pdf"
.LookIn = "I:\Prior_Turbine_A"
.Execute
For i = 1 To .FoundFiles.Count
ActiveSheet.Hyperlinks.Add Anchor:=Range("A" & i), _
Address:=.FoundFiles(i), TextToDisplay:= _
Right(.FoundFiles(i), Len(.FoundFiles(i)) - _
InStrRev(.FoundFiles(i), "\"))
Next
End With
End Sub
 
A

akrashid

try something like this:

Sub Prior_Turbine_A()
Dim i As Long
Dim strSearch As String

strSearch = InputBox("Enter search string")

With Application.FileSearch
.NewSearch
.SearchSubFolders = True
.FileType = msoFileTypeAllFiles
.Filename = "*" & strSearch & "*.pdf"
.LookIn = "I:\Prior_Turbine_A"
.Execute
For i = 1 To .FoundFiles.Count
ActiveSheet.Hyperlinks.Add Anchor:=Range("A" & i), _
Address:=.FoundFiles(i), TextToDisplay:= _
Right(.FoundFiles(i), Len(.FoundFiles(i)) - _
InStrRev(.FoundFiles(i), "\"))
Next
End With
End Sub

--
Hope that helps.

Vergel Adriano








- Show quoted text -

Thanks Vergel, it works great, have a great day and again thanks for
your help.
 
A

akrashid

Thanks Vergel, it works great, have a great day and again thanks for
your help.- Hide quoted text -

- Show quoted text -

Vergel,

One more thing, how can I modify the above code so that the hyperlinks
are sorted in a decending order.

thanks agin in advance!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top