logo
search
VBA & Macro Problems

Fix Excel Images Changing After Saving and Reopening (VBA)

Maira MehtabMaira Mehtab Sep 21, 2026 870 views

Question details

Users experience an issue where images and text boxes inserted into an Excel workbook using VBA macros change, swap, or are replaced by other files from the same directory after the file is saved, closed, and reopened.

Product
Microsoft Excel
Device & OS
not provided
Scenario
Inserting images and shapes into a workbook using the VBA Shapes.AddPicture method and then saving the document.
Observed behavior
Images and text boxes are replaced by different image files located in the same folder when the saved workbook is reopened, even occurring in entirely blank workbooks.
Before you start

Before modifying and testing your VBA macro code, ensure you create a backup copy of your original workbook to prevent unintended data loss or permanent formatting changes.

Solution 1Recommended

Embed Images Instead of Linking in VBA

Modifying the Shapes.AddPicture parameters to embed the image directly into the workbook rather than linking it to the external file directory can prevent the images from dynamically swapping.

By default, VBA might insert images as external links. If the source folder structure changes or Excel misinterprets the linking paths, it can swap the images upon reopening.

1
Open the VBA Editor

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

2
Locate the Shapes.AddPicture Code

Find the module and the specific macro containing your Shapes.AddPicture command.

3
Modify the Parameters

Ensure that the LinkToFile parameter is explicitly set to msoFalse, and the SaveWithDocument parameter is set to msoTrue (e.g., Shapes.AddPicture(FileName, msoFalse, msoTrue, Left, Top, Width, Height)).

4
Save and Test

Save your macro, run the script to insert the images, save the workbook, and then close and reopen it to verify the images remain stable.

Parameter Verification: Explicitly defining both the linking and saving parameters ensures Excel treats the shape as an internal object rather than a dynamic external reference.
Free Microsoft Office alternative

Try WPS Office for Seamless Spreadsheet Management

If Microsoft Excel continues to struggle with image stability when running VBA macros, consider switching to WPS Office. It provides a highly compatible and lightweight spreadsheet environment with robust support for complex data and shapes.

  1. 1. Download WPS Office: Visit the official WPS Office website and download the free installation package.
  2. 2. Install the Software: Run the installer and follow the on-screen instructions to set up WPS Office on your device.
  3. 3. Open Your Workbook: Launch WPS Spreadsheet and open your existing Excel workbook to enjoy a seamless, stable editing experience.
Free to download and use with a highly intuitive, user-friendly interface.Fully compatible with Microsoft Office formats, including .xlsx and .xlsm files.Lightweight design ensures smooth performance even with media-heavy spreadsheets.Provides a reliable environment for managing inserted images, shapes, and data without unpredictable swapping bugs.
microsoft office alternative - wps office

Frequently Asked Questions

Why do Excel images move or resize automatically?

This usually happens because the object properties are configured to move and size with cells. To fix this, right-click the image, select 'Size and Properties', and change the setting to 'Don't move or size with cells'.

What is the difference between LinkToFile and SaveWithDocument in Excel VBA?

LinkToFile determines whether the image remains a dynamic reference to an external file on your hard drive, while SaveWithDocument dictates whether a static copy of the image is permanently embedded inside the workbook itself.

Does WPS Spreadsheet support VBA macros?

Yes, the professional versions of WPS Office fully support VBA macros, allowing you to run, edit, and create automated scripts seamlessly just as you would in Microsoft Excel.

How do I stop VBA inserted images from swapping with other files?

Ensure that your images are embedded rather than linked by explicitly setting the LinkToFile parameter to msoFalse and the SaveWithDocument parameter to msoTrue in your Shapes.AddPicture VBA code.