To open an Excel workbook without triggering its automatic macros, hold down Shift as you open it and keep holding the key until the workbook has finished loading. For a stronger, repeatable safeguard, disable VBA macros in Excel’s Trust Center before opening the file; the Shift method is a one-time way to suppress startup macros, not a way to remove or permanently disable them.
What happens when an Excel file opens
A workbook can contain code that runs automatically when it opens. Common examples are a Workbook_Open event procedure in the workbook’s ThisWorkbook module and an older Auto_Open macro. These procedures might update data, change settings, display forms, or perform other actions. A workbook can also contain macros that run only when someone starts them manually, such as from the Macros dialog or a button.
The distinction matters: suppressing automatic startup code does not delete macros, convert the file to a macro-free format, or prevent a user from deliberately running a macro later. Nor does it necessarily stop code in other open workbooks or add-ins from responding to events. The goal is to keep the file you are opening from launching its own startup macro while you inspect it.
Macro-capable file types include .xlsm, .xlsb, and older .xls workbooks. The standard .xlsx format cannot store a VBA project. A file extension alone is not a safety guarantee: a workbook may contain links, data connections, or other active features even if its macros are disabled.
Use Shift to bypass startup macros once
On Windows, start holding Shift before you open the workbook. You can open it from Excel’s File > Open screen or from File Explorer. Keep the key held while Excel loads the workbook, then release it once the workbook is open. If the workbook is already open, closing and reopening it with Shift held is necessary; pressing Shift afterward cannot undo a macro that has already run.
- Close the workbook if it is already open.
- Hold down the left or right Shift key.
- While continuing to hold Shift, open the file in Excel.
- Keep holding Shift until the workbook has finished opening.
- Check the workbook before enabling content or running any macro manually.
This method is useful when you trust the file enough to inspect it but do not want its normal startup routine to run. It is not an enduring security setting: the next time you open the workbook without Shift, its startup code may run if Excel permits macros. If a managed computer has security policies that override normal settings, follow your organization’s guidance rather than relying on a keyboard workaround.
Choose a macro setting for a stronger safeguard
In Excel for Microsoft 365 on Windows, open File > Options > Trust Center > Trust Center Settings > Macro Settings. For a cautious general setting, choose Disable VBA macros with notification. Excel then blocks macros by default and may show a security notice for files where macros are available. You can leave them disabled while inspecting a workbook. Only enable content when you have a good reason to trust the file and its source.
Disable VBA macros without notification is another option if you want macros disabled without prompts. It can make it less obvious why a workbook’s automated features do not work. Settings can be controlled by workplace administrators, so a choice may be unavailable or may revert. The Trust Center setting applies broadly to Excel, rather than just to one workbook, and it changes the behavior of future files too.
Do not choose Enable VBA macros as a routine workaround for opening a file. It permits VBA macros to run when the workbook is opened or when a user starts them, subject to other protections and policies. If you temporarily change a global setting to inspect one workbook, restore your usual setting afterward.
Open a workbook from VBA with macros disabled
If another macro needs to open a workbook without allowing that workbook’s VBA macros to run, use Excel’s Application.AutomationSecurity property. Set it to msoAutomationSecurityForceDisable immediately before the programmatic open, then restore the previous value. The example opens the selected path read-only and does not update external links; link handling is separate from macro security.
Sub OpenWorkbookWithoutMacros()
Dim filePath As String
Dim previousSecurity As MsoAutomationSecurity
Dim openedWorkbook As Workbook
filePath = "C:\Reports\ReviewFile.xlsm"
previousSecurity = Application.AutomationSecurity
On Error GoTo OpenFailed
' Disable VBA macros in workbooks opened by this code.
Application.AutomationSecurity = msoAutomationSecurityForceDisable
Set openedWorkbook = Workbooks.Open( _
Filename:=filePath, UpdateLinks:=0, ReadOnly:=True)
Application.AutomationSecurity = previousSecurity
Exit Sub
OpenFailed:
Application.AutomationSecurity = previousSecurity
MsgBox "Could not open the workbook: " & Err.Description, vbExclamation
End Sub
This setting concerns files opened programmatically; it is not a permanent replacement for Excel’s Trust Center controls when a person opens files manually. Restoring the previous value is important because the property affects later programmatic opens in the Excel session. The example’s error handler also restores it if the open fails. UpdateLinks:=0 prevents Excel from updating external workbook links during that open; it does not disable macros or make linked data safe.
Before running any VBA macro, save a separate copy of important workbooks. Excel’s Undo command, Ctrl+Z on Windows, does not reverse changes made by VBA. On a Mac, use Command+Z for ordinary undo, but it likewise cannot undo a macro’s actions. The code above is intended for Excel VBA on Windows; Excel for Mac has VBA, but file locations, permissions, and security controls can differ, so adapt the path and check the settings available in your Mac version.
What Shift and macro settings do not protect against
Disabling VBA is one layer of protection, not a guarantee that every workbook feature is harmless. A workbook may request that you update external links, connect to a data source, refresh a query, or enable other content. Treat those prompts separately. If you do not recognize the source or understand why a prompt appears, decline it and ask the sender or your IT team.
Files downloaded from the internet may be subject to additional Microsoft Office protections. On current Windows versions, macros in files marked as coming from the internet are commonly blocked by default, but behavior can depend on Office updates, file origin, and organizational policy. Protected View can also restrict interaction with a file until you choose to enable editing. Do not assume that every workbook will open in Protected View or that a Protected View prompt replaces macro settings.
- Keep macros disabled when you only need to read or review the workbook.
- Do not click Enable Content just to make a warning disappear.
- Verify unexpected files with their sender through a separate, trusted channel.
- Use a managed, isolated environment if your organization requires one for unknown files.
Common problems and how to diagnose them
The macro ran even though Shift was held. The key may have been pressed after opening began or released before Excel finished loading. Close the workbook and try again, keeping Shift down throughout the opening process. Also consider whether the action came from an add-in, another workbook, or an external process rather than the file’s own startup macro.
The workbook opens but its buttons or features do nothing. That may be expected if macros are disabled. A button may be assigned to a VBA procedure, and a form or automated workflow may depend on VBA. Do not enable macros simply to test a button in a file from an unknown source. Ask the file’s owner what the feature does and request a trusted copy or explanation.
I cannot find the Trust Center options. Confirm you are using desktop Excel for Windows and open File > Options. Excel for the web does not run VBA macros and does not provide the same desktop VBA environment, so use the desktop application for these settings. On Mac, use Excel’s application settings or preferences and look for its security or macro controls; menu wording and available choices can vary by release. An organization may also hide or enforce settings.
I need the workbook’s data, not its code. If you only need to inspect values, leave macros disabled and consider opening a copy. If the workbook is trusted and you need a permanently macro-free copy, use Save As and select .xlsx; Excel will warn that VBA content cannot be saved in that format. Do not overwrite the original if its macros may be needed later.
Windows, Mac, and Excel for the web
The main steps here are for Excel for Microsoft 365 on Windows. Windows users can use Shift during opening and can change desktop macro settings through File > Options > Trust Center. Keyboard shortcuts also differ by operating system: Ctrl+Z is the standard Windows undo shortcut, while Mac Excel uses Command+Z for ordinary undo, with the important limitation that neither undoes a VBA macro.
Excel for Mac supports VBA, but its menus and security preferences are not identical to Windows, and administrators may impose different controls. Check the options in the installed Mac release rather than following a Windows menu path literally. Excel for the web can open and edit many workbooks, but it does not run VBA macros. If a workbook depends on VBA, its automation will not operate in the browser; opening it in the web app is not the same as using desktop Excel with macros enabled.
Frequently Asked Questions
Does holding Shift permanently disable macros? No. It suppresses automatic macros for that opening. It does not remove VBA code or change the workbook’s future behavior. Use an appropriate Trust Center setting if you want macros disabled more generally.
Can I open an XLSM file without running its macros? Yes. Hold Shift while opening it, or disable VBA macros in Excel before opening it. The workbook remains an XLSM file and its code remains present; disabling macros prevents execution rather than deleting the code.
Will disabling macros stop a Workbook_Open event? When Excel blocks the workbook’s VBA macros, its Workbook_Open VBA event procedure will not run. Other workbook features, external links, add-ins, or data connections are separate and may have their own prompts or behavior.
Does opening a workbook in Excel for the web run VBA? No. Excel for the web does not run VBA macros. The workbook’s VBA project may remain in the file, but VBA-dependent automation requires a compatible desktop version of Excel.
Is a workbook safe if Excel shows no macro warning? Not necessarily. The absence of a warning is not proof that a file is safe, and a warning’s appearance depends on the file and security settings. Consider where the file came from, keep macros disabled for untrusted files, and do not enable other content you cannot verify.
Related
- Excel Transpose: Turn a List Into a Table
- Excel To-Do List Examples and Simple Templates
- Excel Text Number Format: How It Works and When to Use It
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: Delete a Row If a Cell Is BlankYes. In Excel VBA, loop through the rows from the bottom upward and delete a row when the…
- Dim ws As Worksheet in VBA: Meaning and UseDim ws As Worksheet declares a variable named ws that can refer to an Excel worksheet, but it…
- VBA Open UserForm: How to Show a Form in ExcelTo open a VBA UserForm in Excel, call its Show method: for example, frmCustomer.Show. Replace frmCustomer with the…
- VBA InputBox Yes/No Questions: Use MsgBox CorrectlyVBA’s standard InputBox cannot display Yes and No buttons; it collects text instead. To ask a true yes-or-no…
- Excel VBA Error Handler: How to Catch and Fix ErrorsAn Excel VBA error handler is code that tells a macro what to do when a runtime error…
- VBA Copy and Paste Values Into the Next Empty Row in ExcelTo copy a range as values into the next empty row in Excel, assign the source range’s .Value…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.