How to Fix Excel VBA Workbook_Open Macro Not Running Automatically
Question details
The user needs to resolve an issue where a VBA macro located in ThisWorkbook fails to trigger automatically when the Excel file is opened or copied.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Opening a macro-enabled Excel workbook and expecting the Workbook_Open event to execute automatically.
- Observed behavior
- The Workbook_Open macro does not execute automatically upon opening the file, which is commonly caused by macro security settings, disabled events, or incorrect VBA code placement.
Ensure that your workbook is saved as an Excel Macro-Enabled Workbook (.xlsm) and that you trust the source of the file before altering any macro security settings.
Enable Macros and Adjust Trust Center Settings
The most common reason for an auto-run macro failing to execute is Excel's Trust Center blocking macros by default for security purposes.
By default, Excel disables macros to protect your computer from potentially malicious code. If you do not receive a prompt to enable macros when opening the file, your Trust Center settings may be strictly blocking them.
Open your Excel workbook. Click on 'File' in the top-left corner, select 'Options' at the bottom, and then click on 'Trust Center'. Click the 'Trust Center Settings' button.
Navigate to the 'Macro Settings' tab on the left. Select 'Disable all macros with notification' so Excel prompts you to enable them when opening the file.
If you frequently use this workbook, go to 'Trusted Locations' in the Trust Center, click 'Add new location', and select the folder where your file is saved. Macros in Trusted Locations will run automatically without prompts.

Verify Workbook_Open Code Placement and Syntax
A Workbook_Open event will only trigger if it is placed in the correct specific object module with the exact required naming convention.
Seek Advanced Assistance on Stack Overflow
If security settings and code placement are correct but the macro still fails, the problem may involve deeper script conflicts or disabled application events that require community debugging.
Try WPS Office for Seamless Spreadsheet Management
If you frequently deal with complex Microsoft Office issues, consider switching to WPS Office. It provides excellent compatibility with Microsoft Excel formats, a familiar user interface, and is completely free and lightweight.
- 1. Download WPS Office: Visit the official WPS Office website and download the free installation package.
- 2. Install the Application: Run the installer and follow the quick on-screen instructions to set up WPS Office on your device.
- 3. Open Your Spreadsheets: Double-click your existing .xlsx or .xlsm files to open them instantly in WPS Spreadsheet with full formatting preserved.

Frequently Asked Questions
Why does my macro run perfectly when executed manually but not upon opening?
This usually happens if the macro is not placed inside the 'ThisWorkbook' module, or if the subroutine is not strictly named 'Private Sub Workbook_Open()'. Standard modules do not listen for workbook-level events.
Will saving my file as an .xlsx document remove my macros?
Yes, the standard .xlsx format is macro-free and cannot save VBA code. You must save your document as an Excel Macro-Enabled Workbook (.xlsm) or an Excel Binary Workbook (.xlsb) to retain your VBA scripts.
How do I re-enable events if my VBA macro accidentally turned them off?
If 'Application.EnableEvents = False' was executed and never turned back on, your automatic macros will stop triggering. To fix this, press Alt+F11 to open the VBA Editor, press Ctrl+G to open the Immediate Window, type 'Application.EnableEvents = True', and press Enter.




