NessPJ
Active Member
- Joined
- May 10, 2011
- Messages
- 431
- Office Version
- 365
Hi,
I am currently working on an Excel sheet with VBA that also opens a few other files in the routine etc.
Now i was working on creating an ErrorHandler for the file but i ran into a problem where my "OriginalWorkbook" was no longer
activated because i opened "WorkbookX" and an error would occur.
What would be my best way for the ErrorHandler to safely check/handle Activating the "OriginalWorkbook" and or even closing "WorkbookX" ?
If i use the following construction inside the ErrorHandler when it is called, RTBook could actually be the name of "WorkbookX" instead of "OriginalWorkbook".
RTBook = ActiveWorkbook.Name
Application.Workbooks(RTBook).Activate
Eg. The filename for "OriginalWorkbook" is not a constant and changes on a weekly basis (otherwise i could declare it as a Public Constant).
Is there something like a Public Variable i can use or something?
I am currently working on an Excel sheet with VBA that also opens a few other files in the routine etc.
Now i was working on creating an ErrorHandler for the file but i ran into a problem where my "OriginalWorkbook" was no longer
activated because i opened "WorkbookX" and an error would occur.
What would be my best way for the ErrorHandler to safely check/handle Activating the "OriginalWorkbook" and or even closing "WorkbookX" ?
If i use the following construction inside the ErrorHandler when it is called, RTBook could actually be the name of "WorkbookX" instead of "OriginalWorkbook".
RTBook = ActiveWorkbook.Name
Application.Workbooks(RTBook).Activate
Eg. The filename for "OriginalWorkbook" is not a constant and changes on a weekly basis (otherwise i could declare it as a Public Constant).
Is there something like a Public Variable i can use or something?