View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default VBA File Search Function tweak

1) what does automatically execute mean?

2) you already have that in the .FoundFiles collection.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Nate" wrote in message
...
Hi, I need help tweaking this File Search function to do two things:
1) I want it to automatically execute the two InputBoxes
2) I want it to save the 4 outputted file locations as a variable to
be used later in an Insert statement

Sub Search_files()
Dim FileS As FileSearch
Dim F As Variant
Dim x As Integer
Set FileS = Application.FileSearch
With FileS
.NewSearch
.Filename = InputBox("Insert file name", , "*.jpg")
.LookIn = InputBox("Insert the path", , "C:\abc\def\Download\")
.SearchSubFolders = True
.Execute
End With
x = 1
For Each F In Application.FileSearch.FoundFiles
Cells(x, 1) = F
x = x + 1
Next F
End Sub

Many thanks in advance, _Nate