logo
search
VBA & Macro Problems

How to Use PowerPoint VBA to Round Image and Shape Corners

Algirdas JasaitisAlgirdas Jasaitis Oct 9, 2026 869 views

Question details

The user needs a VBA macro to automate the process of converting all shapes and images in a presentation into rounded rectangles and adjusting their corner radii.

How to Use PowerPoint VBA to Round Image and Shape Corners
Product
Microsoft PowerPoint
Device & OS
not provided
Scenario
Automating bulk formatting tasks across multiple slides using VBA to save time.
Observed behavior
Standard selection methods like ActiveWindow.ShapeRange only process actively selected shapes or throw errors when trying to process unselected elements, failing to iterate through the entire presentation.
Before you start

Before running any macro that alters shapes globally, ensure you save a backup copy of your presentation, as changing shape types programmatically cannot usually be undone and may alter text formatting or alignment.

Solution 1Recommended

Write a Macro to Loop Through All Slides and Shapes

Use a VBA script that iterates through every shape on every slide, converting them into rounded rectangles and setting the corner adjustment value globally.

Relying on ActiveWindow.ShapeRange requires shapes to be manually selected. To affect the entire presentation without manual selection, you must write a nested loop that iterates through all slides, and then through all shapes within those slides.

1
Open the VBA Editor

Press Alt + F11 on your keyboard while your presentation is open to launch the Visual Basic for Applications (VBA) Editor.

2
Insert a new Module

In the VBA Editor, click on 'Insert' in the top menu and select 'Module' to create a blank script window.

3
Write the nested loop script

Declare your variables for the slide and shape (e.g., Dim sld As Slide, shp As Shape). Create a loop starting with 'For Each sld In ActivePresentation.Slides', and inside it, add 'For Each shp In sld.Shapes'.

4
Apply the rounded rectangle format

Inside the shape loop, apply the format by typing 'shp.AutoShapeType = msoShapeRoundedRectangle'. Adjust the corner radius by adding 'shp.Adjustments(1) = 0.15'.

5
Run the macro

Click the 'Run' button in the toolbar or press F5. The macro will process the entire presentation, converting all standard shapes to rounded rectangles.

Write a Macro to Loop Through All Slides and Shapes
Adjusting Corner Roundness: You can modify the '0.15' value in the Adjustments property to increase or decrease the roundness of the corners according to your design preferences.

Automate Presentations with WPS Office VBA

WPS Presentation offers robust VBA compatibility, allowing you to run macros and automate repetitive tasks like rounding shape corners across your entire slideshow with ease.

  1. 1. Open your presentation: Launch WPS Presentation and open the slideshow file you want to edit.
  2. 2. Access the Developer tab: Navigate to the 'Developer' tab on the top ribbon. If it is not visible, enable it in the WPS settings.
  3. 3. Launch the VBA Editor: Click the 'Visual Basic' or 'VBA Editor' button to open the coding environment.
  4. 4. Insert your macro: Go to Insert > Module, and paste your shape-rounding macro code into the text window.
  5. 5. Run the code: Press F5 or click Run to instantly format all shapes in your WPS presentation.
Full support for running Microsoft Office VBA macrosHigh compatibility with .pptm and .ppt presentation formatsLightweight architecture for fast macro executionFamiliar and intuitive tabbed interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does ActiveWindow.ShapeRange throw an error in my VBA macro?

ActiveWindow.ShapeRange requires shapes to be actively selected by the user with the mouse. If nothing is selected or you are trying to process shapes globally in the background, it will throw a compile or runtime error. Using a loop through ActivePresentation.Slides is the proper workaround.

Can I undo a VBA macro after running it?

Most actions performed by a VBA macro, including changing shape types, cannot be undone using the standard 'Undo' button (Ctrl+Z). Always save a backup copy of your presentation before executing a macro that modifies formatting.

How do I change the radius of the rounded corners in the code?

You can modify the corner radius by changing the adjustment value, specifically 'shp.Adjustments(1)'. The value typically ranges from 0 (completely square) to 0.5 (maximum roundness), so experiment with values like 0.1 or 0.2.

Does changing a shape type using VBA affect the image inside it?

If a shape is filled with a picture, changing the AutoShapeType to a rounded rectangle will generally crop the picture to fit the new rounded borders. However, depending on the original shape, you may need to verify that the image proportions remain intact.