PDA

View Full Version : [SOLVED:] VBA - Search explorer for keyword and return file path



mikejo
09-21-2023, 03:01 PM
Hello,

I have a column full of values and a folder containing nested subfolders and thousands of files inside, some of them named exactly as the values in the column.
I would like to search the folder with shell - windows explorer for a value in range and return the resulting file's path in a variable.
I tried accomplishing this by searching through all files in the folder with fso and with dir - fso worked very slow and with dir I did not manage to search through all subfolders. I'm thinking a windows explorer search inside the main folder for the value might work faster, but nothing I tried worked so far.
For more background info... all files in folder and subfolders are .jpg and I'd use the filepaths resulted from the search to insert the jpg files next to their respective values
Is there any way to return the filepath? Any help would be very appreciated!
Thank you!

June7
09-21-2023, 03:19 PM
See if this helps http://allenbrowne.com/ser-59.html

mikejo
09-21-2023, 04:15 PM
Great code, works perfectly and very fast, thanks a lot!!

Aussiebear
09-22-2023, 01:13 AM
Welcome to VBAX mikejo. Thank you for marking your thread as Solved as well.