Bill Hamilton
Board Regular
- Joined
- Mar 30, 2004
- Messages
- 95
I have some VBA code which has been running quite happily for the last two or three years. Starting a couple of days ago it now fails every time with runtime error "Compile error. Automation error". There are no error numbers or codes given. On clicking OK on the error box the processing continues normally, BUT the user is also shown, and is left looking at, the Visual Basic editor screen. Not good. Clicking Help in the error box brings up a web page saying 'Unable to service request'. Useless.
The way things work is that the workbook the users open contains minimal code just to open a second w/b that contains many macros that the users will run using buttons in sheets on the first w/b. This macros file is opened in an Autpen Sub (yeh, yeh, I know, deprecated and all that, but I'm old school and set in my ways). I don't want to have all the macros in the first w/b and wish to keep them separate.
The Autpen will run a macro to check if the macros file is already allocated and will exit the process if so, and lets the users get on with things. If not (usually the case), it will open it and Set its reference to wbMacs, which is Dim'ed 'as Workbook' and is a global variable defined right at the top. Thus it is available in any Sub in the Module and there are some other Subs besides the Autpen where it's used and it pretty-much has to be a global variable. It's a little more complex than that but that's the gist.
When the runtime error is given and the VBE is displayed the line where wbMacs is Dim'ed is highlighted but processng continues after hitting the OK.
I've googled the words in the error message dialog box (i.e. Compile error, Automation error) and nothing seems to fit with this scenario so I'm pretty stuck. And why should it suddenly start doing this with heretofore stable code? Nothing has changed in my system as far as I know. I'm running Win 10 and Office 2016.
Any clues?
The way things work is that the workbook the users open contains minimal code just to open a second w/b that contains many macros that the users will run using buttons in sheets on the first w/b. This macros file is opened in an Autpen Sub (yeh, yeh, I know, deprecated and all that, but I'm old school and set in my ways). I don't want to have all the macros in the first w/b and wish to keep them separate.
The Autpen will run a macro to check if the macros file is already allocated and will exit the process if so, and lets the users get on with things. If not (usually the case), it will open it and Set its reference to wbMacs, which is Dim'ed 'as Workbook' and is a global variable defined right at the top. Thus it is available in any Sub in the Module and there are some other Subs besides the Autpen where it's used and it pretty-much has to be a global variable. It's a little more complex than that but that's the gist.
When the runtime error is given and the VBE is displayed the line where wbMacs is Dim'ed is highlighted but processng continues after hitting the OK.
I've googled the words in the error message dialog box (i.e. Compile error, Automation error) and nothing seems to fit with this scenario so I'm pretty stuck. And why should it suddenly start doing this with heretofore stable code? Nothing has changed in my system as far as I know. I'm running Win 10 and Office 2016.
Any clues?