How to Automatically Run a Clock Macro During a PowerPoint Slide Show
Question details
The user needs a VBA macro, such as a continuous clock, to execute automatically when displaying a specific slide during an active presentation.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Automating VBA scripts to trigger without manual clicking during a live slide show, specifically targeting slides that contain a certain shape.
- Observed behavior
- Attempting to evaluate a shape directly with expressions like 'If Shapes("arclock") = True' results in an error because shape objects cannot be evaluated as boolean values. An event-driven approach is required.
Ensure your presentation is saved as a Macro-Enabled Presentation (.pptm) and that you have enabled macros in your Trust Center settings before starting the slide show.
Use the OnSlideShowPageChange Event Handler
Utilize built-in application events to detect when the slide changes and trigger the clock macro if the required shape is present on the active slide.
Because shapes do not possess True or False properties, you cannot directly check a shape's boolean state. Instead, you must trap the event that fires when a user navigates to a new slide. By intercepting this slide transition, you can check if a specific shape (like 'arclock') exists on the newly active slide, and run your clock code accordingly.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
Create a Class Module (e.g., EventClassModule) and declare a variable with 'WithEvents' to initialize PowerPoint application events so slide transitions can be intercepted.
In your event handler, add the 'OnSlideShowPageChange' subroutine. Write a 'For Each' loop to iterate through the 'ActivePresentation.SlideShowWindow.View.Slide.Shapes' collection.
Within the loop, check if 'Shape.Name = "arclock"'. If the shape is found, call your custom clock updating procedure to start the timer.

Use Duplicate Slides as a Macro Trigger
Create an automatic trigger by utilizing a transition between a standard slide and a duplicate slide that contains the clock shape.
Create and Run VBA Macros Easily with WPS Presentation
WPS Office offers robust support for VBA macros, allowing you to easily automate tasks like running a real-time clock during your slide shows. With a highly compatible VBA environment, you can edit and run your existing PowerPoint macro scripts seamlessly in WPS Presentation.
- 1. Open WPS Presentation: Launch WPS Office and open your .pptm presentation file containing the macro.
- 2. Access Developer Tools: Navigate to the 'Developer' tab on the top ribbon and click on 'Visual Basic' to open the VBA Editor.
- 3. Insert Your VBA Code: Paste your OnSlideShowPageChange event code and clock subroutine into the respective modules and save the file.
- 4. Run the Slide Show: Click 'Play' or press F5 to start your presentation and verify that the automated clock triggers correctly upon slide change.

Frequently Asked Questions
Why does 'If Shapes("arclock") = True' return an error in VBA?
In VBA, a Shape object cannot be evaluated as a Boolean variable (True/False). To check if a shape exists, you must iterate through the slide's Shapes collection using a loop and evaluate whether any shape's Name property matches your target string.
How do I ensure my VBA clock updates continuously during the slide show?
To keep a clock ticking continuously without freezing the presentation, your macro must use a loop accompanied by the 'DoEvents' command, or rely on Windows API timers, ensuring PowerPoint can still process animations and slide transitions.
Why aren't my PowerPoint macros running during the slide show?
Macros may be disabled due to application security settings. Check your Trust Center settings to ensure macros are enabled, verify that the file is saved as a Macro-Enabled Presentation (.pptm), and ensure any Class Modules for application events are properly initialized.




