Fix Excel VBA AddPicture Error 1004 for Image URLs
Question details
Resolve a VBA AddPicture error when inserting an image from a valid URL in a newer Excel build.

- Product
- Microsoft Excel for Microsoft 365
- Device & OS
- not provided
- Scenario
- A macro uses Shapes.AddPicture to insert an image from a URL and worked in an earlier Microsoft 365 build.
- Observed behavior
- The newer build returns run-time error 1004 saying the specified file was not found, even though the image URL is valid.
Open the image URL in a browser and confirm that it displays the image rather than a sign-in or error page. Identify the destination worksheet and cell used by the macro.
Save the image locally before calling AddPicture
Use a local file path instead of the URL to work around builds that do not accept the URL directly.
Open the image URL in a browser, then use the browser's save option to save the image to a local folder. Note its full path and file extension.
In Excel, press Alt+F11 to open the VBA editor. Replace the URL argument in Shapes.AddPicture with the saved image's full local path.
Refer to Shapes and the destination cell through the intended worksheet. For example, after setting ws to ThisWorkbook.Worksheets("Sheet1"), call ws.Shapes.AddPicture with ws.Range("A1").Left and ws.Range("A1").Top for its position.
Return to Excel and run the macro from Developer > Macros. Confirm that the image appears on the intended worksheet.

Download the image in VBA before inserting it on Windows
Use this approach when the macro must fetch a changing image URL automatically.
Check the macro location and Excel build
Use these checks if the local-file workaround does not resolve the error or the behavior differs between builds.
Work with image-rich spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files and continue working with spreadsheets as you migrate, although WPS does not fix Microsoft Excel's VBA build behavior.

Frequently Asked Questions
Why does AddPicture say a valid image URL was not found?
A valid URL may still fail if the Excel build expects AddPicture to receive a local file path. Save the image locally and pass that path to the method.
How do I keep the image in the workbook after deleting the temporary file?
Set LinkToFile to False and SaveWithDocument to True in the Shapes.AddPicture call. Delete the temporary file only after the image has been inserted successfully.
Does the macro have to be in a standard module?
Not necessarily. A standard module is useful for testing, but worksheet references should be explicitly qualified wherever the code is stored.
What should I check if the VBA download returns an error?
Open the URL in a browser and check whether it requires sign-in or returns an error page. In the example macro, inspect the HTTP status reported before trying AddPicture.
Where can I find my Excel build number?
In Excel, go to File > Account and open About Excel. Include the version and build number when reporting a build-specific issue.




