I have a list of URLs to .gif files in an Excel sheet. I want to use VBA to query these websites and insert these images into the same worksheet. I am using Excel 2007.
First you'll want to download the image. There are several methods for doing this. I use the URLDownloadToFile API.
Use the URLDownloadToFile API function to download a file from a URL into a file*:
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
(*visit link for full code)
Then a code sample like this will import them onto the worksheet wherever you like:
From Insert pictures using VBA in Microsoft Excel*:
Sub TestInsertPicture()
InsertPicture "C:\FolderName\PictureFileName.gif", _
Range("D10"), True, True
End Sub
(*visit link for full code)
To be fair to the original authors, I won't repost the code in its entirety here. Apologies for a mostly link-based answer.