Hello,
I'm looking to import a few images into my excel file and I plan on importing the picture by calling the pictures based on their html elements.
The image html code:
My code:
The current code errors out at
The error message says the Object doesn't support this property or method. Any ideas on how to resolve this? Much appreciated.
I'm looking to import a few images into my excel file and I plan on importing the picture by calling the pictures based on their html elements.
The image html code:
HTML:
<img chart-id="2669" alt="Chart ID 2669" class="chart-img" src="https://website.com/569134694870.jpg" diagnostic-id="chart-img-1" style="max-height: 150px;">
My code:
VBA Code:
Sub tt()
Dim strURL As String
Dim ie As Object
Dim Elem
Dim X
Set ie = CreateObject("InternetExplorer.Application")
strURL = "https://website.com/chartbooks/22920"
ie.navigate strURL
ie.Visible = True
Do While (ie.Busy Or ie.readyState <> 4)
DoEvents
Loop
For Each Elem In ie.document.getElementsByTagName("img")
If ie.document.getElementsByTagName("img").getAttribute("alt") = "Chart ID 2669" Then
Worksheets("Sheet1").Range("A1") = ie.document.getElementsByTagName("img").getAttribute("src")
Exit For
End If
Next
End Sub
The current code errors out at
VBA Code:
If ie.document.getElementsByTagName("img").getAttribute("alt") = "Chart ID 2669" Then
The error message says the Object doesn't support this property or method. Any ideas on how to resolve this? Much appreciated.