I am trying to search for a file and after the file is found I need the path put in a string to be used later in the macro. This is the block of code I have so far:
Dim avg As String
With Application.FileSearch
.NewSearch
.LookIn = "C:\My Documents"
.TextOrProperty = "*Average*.xls"
.MatchTextExactly = True
.FileType = msoFileTypeExcelFiles
avg = .FoundFiles ' This is the part that I am having a problem with. I want to put the path in a string.
End With
I want the FileSearch to look for a file that includes the word Average in the name, then I want to get the path for that file and use it later in the macro.
There will be only one file with Average in the name, but it may be in different places in C:\My Documents, depending on which computer the macro is run on.
I don't know if I am on the right track with this or if there is an easier way.
Thanks for helping.