logo
search
VBA & Macro Problems

How to Automatically Start an Excel Running Clock on Workbook Open

WPS EditorWPS Editor Sep 25, 2026 869 views

Question details

The user needs an Excel running clock macro to start automatically as soon as the workbook is opened.

How to Automatically Start an Excel Running Clock on Workbook Open
Product
Excel
Device & OS
not provided
Scenario
Automating a clock macro to trigger immediately upon file load without requiring manual execution.
Observed behavior
The clock macro functions correctly when triggered manually but fails to launch automatically when opening the workbook.
Before you start

Ensure that you have already created the running clock macro procedure (e.g., 'running_clock') in a standard module before setting up the auto-start event.

Solution 1Recommended

Use the Workbook_Open Event in VBA

This method links your existing clock macro to the workbook's open event, ensuring the script runs automatically upon launching the file.

For a macro to execute when a workbook is opened, it must be called from a specific event handler built into Excel's 'ThisWorkbook' object. Placing the call in a standard module will not trigger it on startup.

1
Open the Visual Basic Editor

Press Alt + F11 on your keyboard to open the VBA Editor in Excel.

2
Access ThisWorkbook

In the Project Explorer pane on the left side of the window, find your workbook name and double-click on 'ThisWorkbook'.

3
Add the Open Event Procedure

In the code window, select 'Workbook' from the left dropdown menu to automatically generate a 'Private Sub Workbook_Open()' procedure. Inside this sub, type 'Call running_clock' (replace 'running_clock' with the exact name of your macro).

4
Save as Macro-Enabled

Save your file as an Excel Macro-Enabled Workbook (.xlsm). When reopening the file, ensure you click 'Enable Content' in the security warning to allow the macro to run.

Use the Workbook_Open Event in VBA
Macro Security Warning: Make sure your macro security settings in the Trust Center are configured to allow macros to run, otherwise the workbook will block the script upon opening.
Professional Spreadsheet Editor

Easily Manage and Auto-Run Macros in WPS Spreadsheet

WPS Office fully supports VBA macros, allowing you to easily set up auto-starting clocks, automate repetitive tasks, and manage code within a clean, intuitive interface.

  1. 1. Open WPS Spreadsheet: Launch WPS Office and open your .xlsm file containing the clock macro.
  2. 2. Enable Macros: Click 'Enable Macros' in the security warning prompt located just below the main ribbon.
  3. 3. Access VBA Editor: Go to the Developer tab and click on 'Visual Basic' to view, edit, or test your Workbook_Open event code.
Fully compatible with Microsoft Excel .xlsm and .xlsb formatsBuilt-in VBA editor for seamless macro and event managementLightweight application with exceptionally fast loading speedsFree to use with a highly intuitive user interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Workbook_Open event not trigger?

This usually happens if macros are disabled in your Trust Center settings, or if the code was accidentally placed in a standard module instead of the 'ThisWorkbook' object.

Can I stop the running clock macro once it starts?

Yes. You can assign a boolean variable to track the clock's state and create a separate macro to toggle it to false, stopping the Application.OnTime loop.

What file format must I use for my auto-start macro to work?

You must save your file as a Macro-Enabled Workbook (.xlsm) or an Excel Binary Workbook (.xlsb). Saving as a standard .xlsx will completely remove the VBA code from the file.