VBA & Macro Problems

How to Move an Object or ActiveX Label with PowerPoint VBA Macro

Aamir Naveed AkramAamir Naveed Akram Nov 4, 2026 869 views

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.

How to Move an Object or ActiveX Label Using a VBA Macro in PowerPoint
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the left-hand Project pane, right-click on your presentation, select 'Insert', and choose 'Module'.

3
Paste the Movement Macro

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

4
Assign the Macro to an Object

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.

Modify the Object's .Left Property Using VBA
Slide Refresh Trick: The line 'GotoSlide oSl.SlideIndex' is crucial. It forces the current slide to refresh during the presentation so the movement of the object becomes immediately visible without manually advancing the slide.
Advanced Presentation Features

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. 1. Download and Install: Download WPS Office from the official website and open WPS Presentation.
  2. 2. Enable Macros: Access the Developer tab to open the VBA Editor and insert your custom macro codes.
  3. 3. Build Interactivity: Use built-in Action Settings and shapes to trigger your macros for highly interactive slideshows.
Fully compatible with Microsoft PowerPoint formats including .pptx and .pptmSupports powerful VBA macros for slide automation and interactive elementsLightweight application with a familiar, user-friendly interfaceFree access to high-quality presentation templates and tools
microsoft office alternative - wps office

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.