|
Microsoft Office Application Development
|
|
Macro in Excel Stops After A Workbook.Open CommandIntroductionSometimes Excel VBA behaves unexpectedly. Here is an example: You are running code that is meant to open one or more files using the Workbooks.Open command. As soon as you hold down the shift key when this command is being processed, macro execution stops and your program is terminated entirely. This will even happen if you are e.g. editing an email message in Outlook whilst Excel VBA is processing the code in the background. CauseExcel is designed not to run Auto_Open and Workbook_Open code when a workbook is opened from the User interface whilst holding down the shift key. Unfortunately, this (desired) behaviour also applies when opening workbooks through VBA code. Microsoft has confirmed this is a bug. ResolutionBefore opening a workbook through code, detect if the shift key is pressed and wait until it is released. The code sample below shows you how to do this: Option Explicit This problem has also been listed in the Microsoft knowledge base: Macro in Excel Stops After A Workbook.Open Command, February 26, 2005 FeedbackSince you have managed to reach the end of this article, maybe you would care to write me a small message, expressing your opinion on this article? Click here to write an email message to me. | ||||||||||||||
|
Use the contact page to issue
questions or comments about this website. |