VBA & Macro Problems

How to Fix Excel VBA Shapes.AddPicture Error After Office 2208 Update

Camila MilosovichCamila Milosovich Oct 21, 2026 869 views

Question details

Fix the VBA Shapes.AddPicture method failing when passing an API URL that returns image data instead of a direct static image file.

How to Fix Excel VBA Shapes.AddPicture Error After Office 2208 Update
Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a VBA macro to insert an image into an Excel worksheet via an API endpoint, using ActiveSheet.Shapes.AddPicture with SaveWithDocument set to true.
Observed behavior
The macro code works perfectly in Excel version 2202 but throws an error in version 2208, failing to insert the image.
Before you start

Ensure you have developer tools enabled in Excel, administrative access to modify your VBA macro code, and that you understand how to write or edit basic HTTP requests in VBA.

Solution 1Recommended

Save the API Image to a Local Temporary File First

Bypass the URL parsing issue in Shapes.AddPicture by explicitly downloading the image response to a local drive before inserting it into the worksheet.

Since Office update 2208, the Shapes.AddPicture method struggles to process API endpoints that return dynamic image streams instead of standard image file extensions. Downloading the payload to a local temporary file circumvents this limitation.

1
Create an XMLHTTP request in VBA

Use MSXML2.XMLHTTP or WinHttp.WinHttpRequest.5.1 in your VBA code to send a GET request directly to your API endpoint.

2
Save the response body locally

Use an ADODB.Stream object to read the responseBody from your API call, and use the SaveToFile method to save it as a local .jpg temporary file on your hard drive.

3
Update the Shapes.AddPicture command

Modify the ActiveSheet.Shapes.AddPicture function in your macro to use the local file path instead of the API URL. Ensure SaveWithDocument remains set to true.

4
Delete the temporary file

Clean up your local storage by using the Kill statement in VBA to delete the temporary image file after it has been successfully embedded into the active cell.

Save the API Image to a Local Temporary File First
Wait for API Response: Ensure your VBA code waits for the HTTP request to fully complete and confirms that the local file is entirely saved before attempting to call the AddPicture method.
Free Microsoft Office alternative

Use WPS Office as a Stable Alternative for Macro Execution

If frequent Microsoft Excel updates unexpectedly break your existing macro workflows, consider switching to WPS Office. It provides a highly compatible environment with excellent support for VBA macros, offering a stable alternative that ensures your automated tasks run smoothly without sudden feature regressions.

  1. 1. Download and install WPS Office: Get the free WPS Office suite from the official website and follow the brief installation prompt.
  2. 2. Open your macro-enabled workbook: Launch WPS Spreadsheets and open your .xlsm file containing the Shapes.AddPicture macro.
  3. 3. Enable macros and execute: Click 'Enable Macros' in the security warning banner, then run your VBA scripts smoothly in a stable environment.
Seamless format compatibility with Microsoft Excel files (.xls, .xlsx, .xlsm).Robust VBA and Macro support to keep your automated workflows running.Lightweight architecture ensuring fast loading and execution times.Free to use with a highly familiar, easy-to-navigate spreadsheet interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Shapes.AddPicture fail with API URLs after the Office 2208 update?

Office updates starting from version 2208 altered how Excel parses URLs in the AddPicture method. It now struggles to process API endpoints that dynamically translate parameters and return an image stream rather than pointing to a static file extension.

Can I still use SaveWithDocument=True when using a local file?

Yes. When you download the API response to a local temporary file and pass that file path to Shapes.AddPicture, setting SaveWithDocument to True will successfully embed the image directly into your workbook, just as it did with the URL.

Will reverting to Excel version 2202 fix this VBA error automatically?

Yes, rolling back your Office installation to version 2202 will restore the previous AddPicture functionality. However, updating your VBA code to download the image locally is highly recommended to prevent your macro from breaking during future software updates.