Home » excel » excel – Insert image from URL

excel – Insert image from URL

Posted by: admin April 23, 2020 Leave a comment

Questions:

The following code works fine with most image URL’s, but for this specific URL I am getting errors:

Sub test()
Sheets(1).Shapes.AddPicture "https://images-na.ssl-images-amazon.com/images/M/MV5BYzVlY2JiODct[email protected]._V1_.jpg" _
                          , msoFalse, msoTrue, 100, 100, 500, 600
End Sub

Run-time error ‘1004’: The specified file wasn’t found

Is it caused by the way this specific URL string is specified (not compatible with VBA)? Or do you think it has something to do with the host blocking access? Thanks.

How to&Answers:

Try to look for a *.png pictures. Then it would work.

I have tried with one from the same Amazon website in PNG –

Sub Test()

     Sheets(1).Shapes.AddPicture _
                 "https://images-na.ssl-images-amazon.com/images/I/31TN1u5GEqL.png",  _
                 msoFalse, msoTrue, 100, 100, 500, 600
End Sub

In MSDN they give example with *.bmp file.

Edit:
However, *.jpg works from plenty of other websites. Thus probably Amazon is restricting it.