Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Disabling Shift Key Use when Opening a Workbook.

Disabling Shift Key Use when Opening a Workbook

Written by Allen Wyatt (last updated August 2, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


3

The VBA capabilities of Excel are quite astounding. VBA is a full-blown programming language, which means you can do most anything with it. Some folks have even written entire applications in VBA; applications that build upon the Excel environment to accomplish a specific task.

If you've written such a system, you no-doubt rely on the automatic macros that run when you first start Excel or open a workbook. It is common to use these macros to configure the Excel environment and start the application running. It is frustrating to think that someone could disable your entire system simply by holding down the Shift key when opening the workbook. (Holding the Shift key disables any of the automatic macros associated with a workbook.)

There is no way in Excel to disable the Shift-key bypass of startup macros. The reason is quite simple—security. If this feature could be blocked or disabled it would be possible for macro viruses to start running, without the user being able to do anything about it. This would be very bad.

One possible workaround is to not have the workbook do anything useful if the startup macros are not allowed to run. The default worksheet that displays when the workbook is opened should say something to the effect that the workbook must be opened with the macros enabled in order to function properly. The user could then be directed to close the workbook and try again.

In this default condition, the other worksheets in the workbook could be set to a "very hidden" state. This is done by setting the Visible property of each sheet to xlSheetVeryHidden. With this property set, the worksheets cannot be manually made visible; this can only be done via VBA.

If the user opens the workbook and the macros successfully run, they could hide the default worksheet or simply delete it. The macro could then unhide the "very hidden" worksheets, as necessary, to implement the application in the way desired.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10281) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Disabling Shift Key Use when Opening a Workbook.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Finding Boolean Values

Excel worksheets can contain all sorts of data. One thing you might store in a worksheet is a range of Boolean (TRUE or ...

Discover More

Cut and Paste Formatting

What happens when you copy information from one document and paste it into another? It is possible for what you paste to ...

Discover More

Changing the Footnote Continuation Separator

When you add a really long footnote to a document, it could be that the entire footnote might not fit on the page where ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Finding Other Instances of Excel in a Macro

When processing information using a macro, you may need to know if there are any other instances of Excel running on a ...

Discover More

Using Seek In a Macro

When reading information from a text file, your macro may need to start reading at a place other than the beginning of ...

Discover More

Working while a Macro is Running

If you have a macro that takes a long time to process a workbook, you might want to continue working in Excel while the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is six more than 8?

2022-08-02 05:35:00

Boris

Hi Allen,
I added this under the same article for earlier versions of excel but it belongs here so I am repeating it...
Although I have not found any way of setting it, I have workbooks that include "Shift key on Open" - under <File><Info> section, under <Protect Workbook>. This can be unprotected without a password but it is there ...
Indeed, in my envrionment (WIndows 11 Professional, Office 2019 Professional), the shift key seems always to be ignored and auto_open will always execute (even when there is no "Shift key on Open" under the Protect Workbook) (Workbook_open and otehr event macros will not run if Application.EnableEvents is set to false before opening the workbooks; and I am usually - though not always - presented with the enable of disable macros option message box on opening). Ignoring teh shift key on open may be because I have changed the error handling behaviour (break on all errors and back to break on unhandled errors etc) or something but I have not deliberately trapped the shift key behaviour...
{[fig}]


2016-04-24 19:47:24

Petros

"Holding the Shift key disables any of the automatic macros associated with a workbook" is not accurate.

A user just prevents Workbook events (Open, Activate etc) from firing by holding down the Shift key during startup. Macros work OK as demonstrated in the link provided by Frans

Use the onLoad event handler and protect VBA & customUI using Unviewable+. Read more:

http://www.spreadsheet1.com/unviewable-vba-project-app-for-excel.html


2013-03-13 16:11:51

Frans

Hi Allen,
Great tips, thanks.
Quote: "There is no way in Excel to disable the shift-key bypass of startup macros."
Yes there is a way. See http://pixcels.nl/disable-shift-key-on-open/
Excel!
- Frans


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.