0

I'm working on scheduling an Excel macro to run on a daily basis. This article was my starting point. https://www.thespreadsheetguru.com/blog/how-to-automatically-run-excel-vba-macros-daily

I've worked out most of the issues, but now I need to work on the file that is opened. It will have a timestamp so I need to use a wildcard in this line:

ExcelFilePath = "C:\Users\chris\Documents\My File.xlsm"

Which is later called here:

Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)

I've tried multiple options to include the * but none are working. From the searching I've done, I'm not sure if using it with the Workbooks.Open will work. But, a lot of what I'm finding is VBA related and this is a VBS file so I'm not sure if I'm looking at the right thing or not.

Any ideas? I basically just need to find a file with "*UserAttendance.csv" and then call that file in the .vbs file.

braX
  • 9,702
  • 5
  • 16
  • 29
  • https://stackoverflow.com/questions/10380312/loop-through-files-in-a-folder-using-vba – braX Jan 26 '21 at 23:38
  • 1
    Use the `Scripting.FilesystemObject` to loop over the files in the folder, and check the name until you get a match, then process that file. Similar: https://stackoverflow.com/questions/20905889/vbscript-to-move-file-with-wildcard-if-it-exists – Tim Williams Jan 27 '21 at 01:12
  • Thanks so much!! I'd tried some options with Dir but they didn't work. The Scripting.FilesystemObject worked perfectly though. – Web Services Jan 27 '21 at 21:10

0 Answers0