PowerPoint VBA Alternative to Change Picture Command
Question details
The user needs to find a way to programmatically replace an image using PowerPoint VBA, since there is no direct equivalent to the UI's 'Change Picture' command.

- Product
- Microsoft PowerPoint
- Device & OS
- not provided
- Scenario
- Automating the replacement of images in a presentation via VBA without losing the original image's size, position, formatting, and animations.
- Observed behavior
- PowerPoint VBA lacks a direct .ChangePicture method, requiring developers to write complex workaround scripts to insert new shapes and manually transfer properties.
Ensure you have the Developer tab enabled in your presentation software to access the VBA editor, and always back up your original presentation file before testing custom macros.
Write a Custom VBA Replacement Macro
Since a direct method doesn't exist, you must use a macro that inserts the new image, copies the exact properties from the original image, and then deletes the old one.
Replacing an image programmatically requires careful handling of the shape's attributes. A basic insertion will place the image at the top of the z-order with default dimensions.
Your script must explicitly capture the Top, Left, Height, and Width properties of the old shape and apply them to the new picture to maintain the layout.
Declare variables in your VBA script to store the `.Top`, `.Left`, `.Height`, `.Width`, and `.ZOrderPosition` of the selected image you wish to replace.
Use the `ActiveWindow.Selection.SlideRange.Shapes.AddPicture` method to insert the new image file onto the slide.
Assign the captured position and size variables to the newly inserted shape. Use the `ZOrder` method to move the new shape backward until it matches the original stack position.
Once the new image is perfectly positioned and formatted, use the `.Delete` method on the original shape object to complete the replacement.

Simplify Presentation Editing with WPS Office
If writing complex VBA macros in Microsoft PowerPoint just to replace an image is slowing you down, consider switching to WPS Office. It provides an intuitive interface for seamless presentation editing, excellent format compatibility, and all the essential tools you need without the steep price tag.
- 1. Download and Install: Visit the official WPS website to download the free WPS Office installer and complete the quick installation process.
- 2. Open Your Presentation: Launch WPS Presentation and easily open your existing .pptx or .pptm files without losing any formatting.
- 3. Edit Without Hassle: Right-click any image and use the built-in 'Change Picture' feature to instantly swap visuals without needing to write custom macros.

Frequently Asked Questions
Why doesn't PowerPoint VBA have a simple Change Picture command?
The PowerPoint object model does not expose the user interface's 'Change Picture' function directly to VBA. As a result, developers must manually code the insertion of new shapes and the transfer of all relevant properties.
Can I keep my image animations when using a macro to replace pictures?
A basic macro will lose animations because the newly inserted image is recognized as a completely different object. You must explicitly read the animation timeline settings of the old shape and recreate them for the new shape in your code.
Does deleting the original image affect the z-order of my slide?
Yes. When you insert a new image, it automatically appears at the front (top of the z-order). You must use the .ZOrder method (such as msoSendBackward) in your macro to push the new picture back to the original image's layer position before deleting the old one.
Will replacing pictures via VBA break hyperlink functionality?
Yes, standard image replacement via VBA will drop hyperlinks. You must capture the ActionSettings or Hyperlink properties of the original image and assign them to the new image programmatically.




