vbaexcelweb-scraping

Insert image from URL


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/MV5BYzVlY2JiODctNGMzNC00OWE5LTg3MTEtNDQ3NDYxNjIxNTBiXkEyXkFqcGdeQXVyNTM3MDMyMDQ@._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.


Solution

  • 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.