-1

I am currently using the following VBA code to open the website on IE:

Set IE = CreateObject("internetexplorer.application")
    IE.Visible = True
    IE.Navigate "http://test.com"

I now need to download an image from the website as a .gif which has the following source (from using inspect element):

<img src="test.php" align="left">

Any advise on how I could do this please?

pnuts
  • 58,317
  • 11
  • 87
  • 139
WPZA
  • 841
  • 1
  • 10
  • 27
  • use URLDownloadToFile function of urlmon , there are too many tutorials about that function – milevyo Oct 14 '15 at 18:56
  • I need the image on the page at that moment in time, it is an animated gif and resets every time you re-load the page. – WPZA Oct 14 '15 at 19:15
  • 1
    Following @milevyo's reply, [Googling around](https://www.google.com/search?q=URLDownloadToFile&oq=URLDownloadToFile+&aqs=chrome..69i57&sourceid=chrome&es_sm=93&ie=UTF-8#q=urldownloadtofile+vba) finds many promising pages. Have you tried looking into that? Also, see [Chip Pearson's](http://www.cpearson.com/excel/downloadfile.aspx) page on downloading files. – BruceWayne Oct 14 '15 at 19:20
  • what you mean by live image?. an image on every instance or animated gif? – milevyo Oct 14 '15 at 19:42

1 Answers1

0
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





Private Sub Command1_Click()
    Dim sin As String
    Dim sout As String

    Dim ret As Long

    sin = "https://upload.wikimedia.org/wikipedia/commons/0/0e/Balle.gif"
    sout = Environ("HOMEPATH") & "\Desktop\" & "image.gif"

    ret = URLDownloadToFile(0, sin, sout, 0, 0)
    If (ret = 0) Then MsgBox "Succedded" Else MsgBox "failed"
End Sub
milevyo
  • 2,165
  • 1
  • 13
  • 18