run time error

klatlap

Well-known Member
Joined
Sep 1, 2004
Messages
597
trying to learn something new, am follow some stuff on your tube but getting a run time error 13, not sure what.

Code:
Sub BrowseToSite()
    Dim IE As New SHDocVw.InternetExplorer
    Dim HTMLDoc As MSHTML.HTMLDocument
    Dim HTMLInput As MSHTML.IHTMLElement
    Dim HTMLAs As MSHTML.HTMLElementCollection
    Dim HTMLA As MSHTML.IHTMLElement
    
    IE.Visible = True
    IE.Navigate "x-rates.com"
    Do While IE.ReadyState <> READYSTATE_COMPLETE
    Loop
    
    Set HTMLDoc = IE.Document
    
    Set HTMLInput = HTMLDoc.getElementById("amount")
    HTMLInput.Value = 5
    
    Set HTMLInput = HTMLDoc.getElementById("from")
    HTMLInput.Value = "GBP"
    
    Set HTMLInput = HTMLDoc.getElementById("to")
    HTMLInput.Value = "USD"
    
    Set HTMLAs = HTMLDoc.getElementsByTagName("A")
    
    For Each HTMLA In HTMLAs
    Debug.Print HTMLA.getAttribute("classname"), HTMLA.getAttribute("href"), HTMLA.getAttribute("rel")
    Next HTMLA
    
    
    End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,696
Try deldaring HTMLAs as follows...

Code:
Dim HTMLAs As MSHTML.IHTMLElementCollection

Hope this helps!
 

Forum statistics

Threads
1,136,341
Messages
5,675,206
Members
419,553
Latest member
hanahass

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top