How to Move an Object or ActiveX Label with PowerPoint VBA Macro
Question details
The user wants to learn how to write a VBA macro to move an ActiveX control (such as a label) a specific distance to the right each time a trigger button is pressed.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Creating interactive presentation slides where shapes or ActiveX controls dynamically change position upon user interaction during the slideshow.
- Observed behavior
- To achieve dynamic object movement on a slide, a macro must execute position modifications and force the slide view to refresh so the change becomes visible immediately.
Ensure that the Developer tab is enabled in your presentation software's ribbon and that you save your file as a Macro-Enabled Presentation (.pptm) to preserve your VBA code.
Modify the Object's .Left Property Using VBA
Create a VBA macro that increments the shape's horizontal position coordinate and forces the slide to refresh.
PowerPoint VBA measures object positions in points, where 72 points equal exactly one inch. By referencing the specific shape (like 'Label1') in your VBA code, you can incrementally adjust its position each time the macro is triggered.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the left-hand Project pane, right-click on your presentation, select 'Insert', and choose 'Module'.
Copy and paste the following VBA code into the module window: Option Explicit Sub NudgeTheLabel(oSh As Shape) Dim oSl As Slide Set oSl = oSh.Parent With oSl.Shapes("Label1") .Left = .Left + 72 End With ActivePresentation.SlideShowWindow.View.GotoSlide oSl.SlideIndex End Sub
Return to your slide view. Insert a shape or Action Button to act as your trigger. Right-click the object, select 'Action Settings', click on 'Run Macro', and select 'NudgeTheLabel' from the dropdown list.

Create Interactive Slides with WPS Presentation
WPS Office provides robust support for slide design, advanced animations, and VBA macros (in supported versions), allowing you to create dynamic and interactive presentations effortlessly.
- 1. Download and Install: Download WPS Office from the official website and open WPS Presentation.
- 2. Enable Macros: Access the Developer tab to open the VBA Editor and insert your custom macro codes.
- 3. Build Interactivity: Use built-in Action Settings and shapes to trigger your macros for highly interactive slideshows.

Frequently Asked Questions
How do I move an object vertically instead of horizontally in PowerPoint VBA?
To move an object up or down, modify the `.Top` property instead of the `.Left` property in your VBA code. For example, adding `.Top = .Top + 72` will move the specified object down by one inch, while subtracting from it will move the object up.
Why isn't my object moving when I click the button during the slideshow?
First, ensure macros are enabled in your Trust Center settings. Second, verify that the macro is properly assigned to the button via the 'Action Settings' menu. Finally, ensure your code includes the slide refresh command (`GotoSlide oSl.SlideIndex`) so the visual update renders instantly during the slideshow.
What unit of measurement does PowerPoint VBA use for object positioning?
PowerPoint VBA strictly measures positions and dimensions in points. There are exactly 72 points in one inch, and approximately 28.35 points in one centimeter. Adjust the increment value in your code accordingly for smaller or larger movements.




