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

Using Dot Leaders in a Paragraph

Adding dot leaders to your text is easy through the application of tab stops. This tip explains the steps you need to ...

Discover More

Turning Off Names

You can use some of the tools in Excel to convert cell references in formulas into names. Converting back (from names ...

Discover More

Creating Two Versions of the Same Document

You may often need to create two versions of the same document, one with everything and the other with a subset of what ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Selecting to the Bottom of a Column in a Macro

Need to select a range of cells in a column? This tip can help, as it shows how to select from a specific cell all the ...

Discover More

Progression Indicator in a Macro

When your macro is humming along, minding its own business, a user watching the screen may not see any activity and ...

Discover More

Determining an ANSI Value in a Macro

Need to know the character code used for a particular character? In a macro you can use the Asc function to determine 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 eight less 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.