ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA File Search Function tweak (https://www.excelbanter.com/excel-discussion-misc-queries/168869-vba-file-search-function-tweak.html)

Nate[_3_]

VBA File Search Function tweak
 
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

Bob Phillips

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





All times are GMT +1. The time now is 05:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com