How to Resize and Arrange Multiple Pictures in PowerPoint using VBA
Question details
The user needs a VBA macro to process six selected images simultaneously, resize them while preserving proportions, arrange them in a 2-column by 3-row grid, and send them behind other objects on the slide.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Automating the sizing and precise layout of multiple images inserted into a presentation slide.
- Observed behavior
- The macro should lock the aspect ratio, set a uniform height of 179.28, assign precise X/Y coordinates for the grid placement, and apply a command to send the images to the back layer.
Ensure you have enabled the Developer tab in your presentation software to access the Visual Basic editor, and save a backup of your current presentation before running any new macros.
Use a VBA Macro to Process and Arrange the ShapeRange
Create a macro that targets the currently selected images, iterates through them to apply specific dimensions, and moves them to predefined coordinate positions in a 2x3 grid.
By utilizing the ShapeRange object in VBA, you can easily manipulate multiple selected objects at once. Processing the shapes in reverse order or assigning precise coordinates directly based on an index allows you to perfectly align the six images into two columns and three rows.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in your presentation software.
In the VBA editor, click 'Insert' from the top menu, then select 'Module' to create a new blank script window.
Create a Sub procedure and set up a loop to iterate through ActiveWindow.Selection.ShapeRange. Inside the loop, apply .LockAspectRatio = msoTrue and set the .Height property to 179.28.
Use a Select Case statement or an array to assign the .Left and .Top positions for each of the six shapes based on their index: (479.52, 0), (720, 0), (479.52, 180.72), (720, 180.72), (479.52, 360.72), and (720, 360.72).
Add the command .ZOrder msoSendToBack for each shape within the loop so the resized images sit cleanly behind text or other objects on your slide.
Return to your slide, select the six images you want to format, go back to the VBA editor, and press F5 to run the macro.

Create and Run Macros Easily in WPS Presentation
WPS Office provides powerful presentation tools with advanced support for VBA macros. You can seamlessly run customized scripts to format your slides, arrange shapes, and automate repetitive presentation tasks.
- 1. Download and Install: Download WPS Office for free from the official website and install it on your computer.
- 2. Open your Presentation: Launch WPS Presentation and open your presentation file (.pptx or .pptm).
- 3. Enable Developer Tools: Navigate to the Developer tab to access the Macro options and the Visual Basic editor.
- 4. Run VBA Scripts: Paste your custom VBA formatting code, select your target images, and run the macro to automatically arrange your slides.

Frequently Asked Questions
Why is my VBA macro throwing an error when I try to run it?
This usually happens if you haven't selected any shapes on the slide before running the macro. The ActiveWindow.Selection.ShapeRange command requires you to manually click and select the six images on the slide first.
Can I adjust the macro to arrange more than six images?
Yes, you can modify the macro by adding more coordinate pairs to your array or Select Case statement. Simply calculate the new Top and Left positions to accommodate additional rows or columns.
How do I save a presentation that contains a VBA macro?
You must save your file as a Macro-Enabled Presentation (.pptm). If you save it as a standard presentation (.pptx), your presentation software will remove the VBA code for security reasons.
What does LockAspectRatio do in PowerPoint VBA?
Setting LockAspectRatio to msoTrue ensures that when you change the height of the image, the width adjusts automatically in proportion. This prevents the picture from looking stretched, squashed, or distorted.




