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

Creating an Excel Workbook from within Word

Word and Excel are both programs within the Microsoft Office suite. If you use both of these programs often, you may ...

Discover More

Comma-Delimited and MS-DOS CSV Variations

Excel provides different file formats you can use to export your worksheet information. One such file format is CSV, or ...

Discover More

Jumping to a Relative Footnote

Footnotes can be a great addition to any document that needs detailed referencing of citations. You can navigate from one ...

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)

Calculating an ISBN Check Digit

ISBNs are used to uniquely identify books. You may need to know if an ISBN is valid or not, which involves calculating ...

Discover More

Notification when Recalculation is Done

If you manually recalculate your workbooks, you are probably doing so because of the time it takes to do the ...

Discover More

Selecting Columns in VBA when Cells are Merged

If you have a macro that selects different columns in a worksheet while processing information, you may get some ...

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 6 - 0?

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.