Fix Excel Workbook_Open Macro Not Running on File Open
Question details
The user's Workbook_Open macro does not execute automatically when an XLSM file is opened.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Opening an Excel file (.xlsm) containing an automated Workbook_Open macro event.
- Observed behavior
- The macro fails to run automatically upon file opening due to macro security blocks, untrusted folder locations, or incorrect code placement.
Verify that your file is saved as an Excel Macro-Enabled Workbook (.xlsm) and only proceed to enable macros if you fully trust the file's source, as malicious macros can pose significant security risks.
Add the File Folder to Trusted Locations
Excel blocks automatic macro execution for files opened from untrusted folders. Adding your specific folder to Trusted Locations bypasses security prompts for safe files.
By designating a specific folder as a Trusted Location, any macro-enabled file placed inside it will automatically run its Workbook_Open event without requiring you to manually click 'Enable Content' every time.
Open Microsoft Excel, click on 'File' in the top-left corner, and select 'Options' at the bottom of the sidebar.
In the Excel Options window, select 'Trust Center' from the left pane, then click the 'Trust Center Settings...' button.
Select 'Trusted Locations' from the left menu and click on the 'Add new location...' button at the bottom.
Click 'Browse' to locate the folder containing your .xlsm file. Check the box for 'Subfolders of this location are also trusted' if necessary, then click 'OK' on all windows to apply the changes.

Enable Macros with Notification in Trust Center
Adjust your global macro settings to ensure you are prompted to enable macros rather than having them blocked silently.
Verify Code Placement in the ThisWorkbook Module
A Workbook_Open event will only trigger if the VBA code is placed in the correct object module.
Run Excel Macros Seamlessly with WPS Office
WPS Spreadsheet offers robust compatibility with Microsoft Excel VBA macros. You can easily manage macro security settings, designate trusted environments, and run your Workbook_Open scripts smoothly in a lightweight, high-performance workspace.
- 1. Open File in WPS Spreadsheet: Launch WPS Office and open your macro-enabled .xlsm workbook.
- 2. Access Developer Tools: Navigate to the 'Developer' tab located in the top ribbon menu.
- 3. Adjust Macro Security: Click on 'Macro Security' and set your preference to 'Medium' (prompts you before running macros) or 'Low' (for strictly trusted local files).
- 4. Reopen and Run: Save your settings, close the file, and reopen it. WPS Spreadsheet will now properly trigger the Workbook_Open event.

Frequently Asked Questions
Why does my Workbook_Open macro run manually but not automatically?
This happens when the code is placed in a standard Module (like Module1) instead of the 'ThisWorkbook' object. The Workbook_Open event is explicitly tied to the workbook object and will only trigger automatically when placed in the ThisWorkbook module.
Is it safe to add my Downloads folder to Trusted Locations?
No, it is highly discouraged. The Downloads folder frequently receives files from the internet. If you add it to Trusted Locations, malicious macros in downloaded files could execute automatically. Only add specific, secure folders where you manually save verified files.
What happens if I save a macro in a standard .xlsx file?
Excel will not save the macro code. Standard .xlsx files do not support VBA code. Macros must be saved in macro-enabled formats such as .xlsm or .xlsb. If saved as .xlsx, the Workbook_Open event and all other macros will be permanently deleted upon closing.
Does WPS Office support Workbook_Open VBA macros?
Yes, WPS Office (specifically the Spreadsheet application) supports VBA macros, including workbook and worksheet events like Workbook_Open, providing high compatibility with existing Microsoft Excel macro files.




