Import .BMP File From Web Using VBA

  • Thread starter Thread starter Donnie Stone
  • Start date Start date
D

Donnie Stone

Does anyone have a quick solution for saving a .bmp file from a WEB page
into excel using VBA?

Thanks,
Donnie
 
Hi Donnie,

Here is a quick solution with API.


Code:
--------------------

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

Sub Test()
'Change url to the bmp
Const strUrl As String = "http://www.exceltip.com/images/newsite/hdr_bg.jpg"
Dim strSavePath As String
Dim returnValue As Long
strSavePath = ThisWorkbook.Path & "\" & "Test.jpg" 'Change Ext as .bmp
returnValue = URLDownloadToFile(0, strUrl, strSavePath, 0, 0)
MsgBox IIf(returnValue = 0, "Succeed!", "Not succeed!")
End Sub

--------------------
 
Back
Top