Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
I have an enterprise application that generates an Excel Workbook. It automatically creates it's own unique name for each report it generates. The workbook name always starts with "Active_Report_" and then is completed with a random set of numbers followed by ".xlsx"
I have an Excel VBA based application that needs to reference that particular workbook created at that time. Since the workbook always has a different name, I can't define it in code (easily) as it's dynamic.
Is there a way that I can assess the names of any open workbooks, and seek out the open one with a name "Active_Report * .xlsx" and set that workbook name to the variable declared as a workbook? (Note: not all files generated by this enterprise application creates this format of a filename. The only thing each and every file name has in common is "Active_Report" and ".xlsx")
Eg. using pseudo-code
enterprise creates and opens for viewing Excel workbook: "Active_Report-2023-1103T1104100.321.xlsx"
I have an Excel VBA based application that needs to reference that particular workbook created at that time. Since the workbook always has a different name, I can't define it in code (easily) as it's dynamic.
Is there a way that I can assess the names of any open workbooks, and seek out the open one with a name "Active_Report * .xlsx" and set that workbook name to the variable declared as a workbook? (Note: not all files generated by this enterprise application creates this format of a filename. The only thing each and every file name has in common is "Active_Report" and ".xlsx")
Eg. using pseudo-code
enterprise creates and opens for viewing Excel workbook: "Active_Report-2023-1103T1104100.321.xlsx"
Code:
Public wb_data as worbook
Dim wbname as string
wbname = full name of the workbook identified as "Active_Report ??????.xlsx" from among the open workbooks
Set wb_data = workbook(wbname)