Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

excel - Open webpage and save image

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...