Fix Excel Workbook_Open Not Running from a Hyperlink
Question details
The user needs a VBA Workbook_Open procedure to execute consistently and resize the Excel window when the file is opened via a hyperlink.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Opening an Excel workbook containing a Workbook_Open macro through a hyperlink while another workbook is already active.
- Observed behavior
- The Workbook_Open macro fails to trigger or works inconsistently when the file is opened from a hyperlink, despite running perfectly when executed manually.
Ensure that macros are fully enabled in your Excel Trust Center settings and verify that the file's directory is added as a Trusted Location.
Verify File Explorer Execution and Security Settings
Confirm that the macro failure is caused by hyperlink security restrictions rather than a broken script or global macro disablement.
When workbooks are launched via hyperlinks, Excel often applies stricter security protocols or opens them in Protected View, which can silently suppress the Workbook_Open event.
Navigate to the folder containing your target workbook using Windows File Explorer and double-click the file to open it directly. Verify if the Workbook_Open macro triggers successfully.
In Excel, go to File > Options > Trust Center > Trust Center Settings. Select 'Macro Settings' and ensure 'Enable VBA macros' is checked.
Under 'Trusted Locations' in the Trust Center, click 'Add new location' and select the folder where your workbook is stored to prevent Protected View from blocking the macro.
Use a Dedicated Macro Button or Quick Access Toolbar Command
Bypass hyperlink limitations entirely by using a dedicated button or toolbar command to reliably open the workbook and trigger the resizing script.
Try WPS Office for Seamless Macro Execution
If Microsoft Excel's hyperlink security settings continue to block your essential VBA scripts, consider switching to WPS Office. It provides robust VBA macro support and full compatibility with Excel files, allowing you to execute complex workflows smoothly without unnecessary hyperlink restrictions.
- 1. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite.
- 2. Open Your Macro-Enabled Workbook: Launch WPS Spreadsheet and open your .xlsm file containing the Workbook_Open scripts.
- 3. Enable Macros and Run: Click 'Enable Macros' when prompted by the security warning to run your window-resizing scripts effortlessly.

Frequently Asked Questions
Why does my Workbook_Open macro run manually but not when clicked from a hyperlink?
When opening a file via a hyperlink, Office applications often launch the file in a restricted or Protected View context. This security measure prevents potentially malicious automatic macros from executing, silently ignoring the Workbook_Open event.
Can I use the Auto_Open macro instead of the Workbook_Open event?
Yes, sometimes placing an older Auto_Open macro inside a standard VBA module behaves differently than the Workbook_Open event attached to 'ThisWorkbook'. While it may bypass certain initialization issues, it is still subject to standard macro security settings.
How do I force macros to run when a file is opened from an intranet link?
You need to add the intranet server or network path to your Excel Trust Center's Trusted Locations. Additionally, ensure that your network settings in Internet Options classify the link as part of the 'Local intranet' zone rather than the public internet.





