Fix Excel Images Changing After Saving and Reopening (VBA)
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 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.
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.
Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications (VBA) editor.
Find the module and the specific macro containing your Shapes.AddPicture command.
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)).
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.
Isolate the Issue in a Blank Workbook
Testing your VBA code in a brand-new workbook helps determine whether the issue is caused by file corruption in your existing document or a bug within the code itself.
Seek Advanced VBA Community Support
If the issue persists despite embedding the images, it may be a specific environmental bug requiring advanced troubleshooting from the VBA developer community.
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. Download WPS Office: Visit the official WPS Office website and download the free installation package.
- 2. Install the Software: Run the installer and follow the on-screen instructions to set up WPS Office on your device.
- 3. Open Your Workbook: Launch WPS Spreadsheet and open your existing Excel workbook to enjoy a seamless, stable editing experience.

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.




