holding down shift key to prevent workbook_open code

conception_native_0123

Well-known member
Local time
Today, 11:04
Joined
Mar 13, 2021
Messages
1,923
if i open excel blank and no workbook, i able to open another book in that instance holding down shift and the code on open event does not run. is this true for all office programs? thank you. is there any other to do?
 
The shift bypass stops code running in Access as well. As all Office programs use VBA, I expect its also true for the rest of the Office programs
 
No, shift bypass is not available to bypass Excel workbook open code. If you are experiencing something that looks like it's working, it's probably because that particular workbook is opening, at that particular time, with macros disabled.

At least on Office 365, I just tried holding down Shift while opening a workbook, and it did not bypass workbook_open code - the code still ran.
And it has never worked for me before in 20 years of using workbook open code.

One thing you can do is disable macros, then open the workbook with the code.
 
According to this article Disable Shift key on open • Pixcels.nl, the Shift bypass key DOES disable to Workbook_Open event.
However, it is possible to over-ride this behaviour by customising the ribbon. If so, pressing the shift key has no effect
 
Did a little bit more testing to try to discover the discrepancy.

Just tested it 5 times in a row on my xlsb, which has a Msgbox in the Workbook Open event. Shift bypass doesn't work.

However, I tested it on an xlsm file, and it caused the enable/disable macros window to be shown, and even when I press enable, the Msgbox is not shown - so apparently the code is being bypassed.

My conclusion from testing, then, is that it works on XLSM, but not XLSB. It makes sense, then, that it works for "some" but has not worked in years for me....I never use xlsm for Excel development.

Thanks @isladogs, I learned something new - one more reason to add to my list why to use XLSB only.
 

Users who are viewing this thread

Back
Top Bottom