2015-07-02 100 views

回答

1

假設你的圖片網址的例子是非常接近你真正想要的,你可以用一個小「網頁抓取」做到這一點:

首先,你必須添加以下兩個引用

  1. Microsoft Internet控制
  2. Microsoft HTML對象庫

Sub extract() 
    Dim IE As InternetExplorer 
    Dim html As HTMLDocument 

    Set IE = New InternetExplorerMedium 
    IE.Visible = False 
    IE.Navigate2 "https://www.google.com/images/srpr/logo11w.png" 

    ' Wait while IE loading 
    Do While IE.Busy 
     Application.Wait DateAdd("s", 1, Now) 
    Loop 

    Set html = IE.document 

    Dim webImage As Variant 
    Set webImage = html.getElementsByTagName("img") 

    'Debug.Print webImage(0).Width 
    'Debug.Print webImage(0).Height 

    MsgBox ("Image is " & webImage(0).Width & " x " & webImage(0).Height) 

    'Cleanup 
    IE.Quit 
    Set IE = Nothing 
End Sub 

結果:

enter image description here

相關問題