VBA & Macro Problems

Fix Excel VBA AddPicture Error 1004 for Image URLs

Camila MilosovichCamila Milosovich Nov 18, 2026 868 views

Question details

Resolve a VBA AddPicture error when inserting an image from a valid URL in a newer Excel build.

Fix Excel VBA AddPicture Error 1004 for Image URLs
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.
Before you start

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.

Solution 1Recommended

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.

1
Save the image

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.

2
Update the macro

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.

3
Qualify the worksheet

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.

4
Run the macro

Return to Excel and run the macro from Developer > Macros. Confirm that the image appears on the intended worksheet.

Save the image locally before calling AddPicture
Embed the image: To keep the picture in the workbook rather than link to the local file, set LinkToFile to False and SaveWithDocument to True in the AddPicture call.
Free Microsoft Office alternative

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.

Insert and arrange pictures in spreadsheetsCompatible with Microsoft Excel XLSX and XLS formatsFamiliar interface for everyday spreadsheet editingFree and lightweight for easy migration
microsoft office alternative - wps office

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.