Good evening! This is my first post, hopefully I get it right.
I have a .XLSM with my macros in it, but as part of my monthly update I need the user to download data from a website that results in a .csv in the downloads folder that users typically click which opens it in excel.
While I can capture my .XLSM file as an object, I'm not sure how a dynamically named file that follows a bit of a mask can be selected and captured as a second object my VBA can work with.
Dim WB1 As Workbook
Dim WB2 As Workbook
' Capture current workbook that is my static .xlsm, not a problem
Set WB1 = ActiveWorkbook
' Open new workbook... this is my problem, the file mask will be... "agency*_alerts_*.csv"... but I'm not sure how to dynamically find that other open spreadsheet to capture it as an object
Workbooks.Open Filename:="C:\Users\[user]\Downloads\agency*_alerts_*.csv"
' Capture new workbook
Set WB2 = ActiveWorkbook
' Go back to original workbook
WB1.Activate
Thanks in advance for any shared wizadry!!
I have a .XLSM with my macros in it, but as part of my monthly update I need the user to download data from a website that results in a .csv in the downloads folder that users typically click which opens it in excel.
While I can capture my .XLSM file as an object, I'm not sure how a dynamically named file that follows a bit of a mask can be selected and captured as a second object my VBA can work with.
Dim WB1 As Workbook
Dim WB2 As Workbook
' Capture current workbook that is my static .xlsm, not a problem
Set WB1 = ActiveWorkbook
' Open new workbook... this is my problem, the file mask will be... "agency*_alerts_*.csv"... but I'm not sure how to dynamically find that other open spreadsheet to capture it as an object
Workbooks.Open Filename:="C:\Users\[user]\Downloads\agency*_alerts_*.csv"
' Capture new workbook
Set WB2 = ActiveWorkbook
' Go back to original workbook
WB1.Activate
Thanks in advance for any shared wizadry!!