Help using Excel VBA to control Explorer

drmingle

Board Regular
Joined
Oct 5, 2009
Messages
229
A gracious individual posted a solution to my problem here:
http://www.mrexcel.com/forum/showthread.php?p=2172141#post2172141
However, the solution doesn't work for me. For whatever reason I can't install (MICROSOFT INTERNET CONTROLS) or (MICROSOFT HTML OBJECT LIBRARY).

I need help finding out how to find and install these references or I need help with an alternate solution. I currently receive object errors when running the below code.

Thanks for reviewing.


Code:
Sub Medicare()
    'reference: Microsoft Internet Controls
    'reference: Microsoft HTML Object Library
 
    Dim Ie As InternetExplorer
    Dim arr, a
 
    Set Ie = New InternetExplorer
    Ie.Visible = True
    '##############################################################################
    '*******************Choose Physician or Other HealthCare Provider**************
    '##############################################################################
    Ie.navigate ("[URL]http://www.medicare.gov/Physician/Se...cianSearch.asp[/URL]")
    Do
        If Ie.readyState = READYSTATE_COMPLETE Then
            Ie.Visible = True
            Exit Do
        Else
            DoEvents
        End If
    Loop
 
    Do Until Ie.document.readyState = "complete"
 
    Loop
     'USE VIEW SOURCE TO GET FORM ELEMENT IDS
    Set arr = Ie.document.getElementsByName("btnSubmit")
 
    For Each a In arr
 
        a.Click
 
    Next a
 
    Do Until Ie.document.readyState = "complete"
 
    Loop
 
    Set arr = Ie.document.getElementsByName("btnSubmit")
 
    For Each a In arr
 
        If a.Value = "Find a Physician" Then
 
            a.Click
 
            Exit For
 
        End If
 
    Next a
 
    Do Until Ie.document.readyState = "complete"
 
    Loop
 
    Set arr = Ie.document.getElementsByName("Type")
 
    For Each a In arr
 
        If a.Value = "STATE" Then
 
            a.Click
 
            Exit For
 
        End If
 
    Next a
 
End Sub
 
You don't actually need the references.

I don't have time at the moment to post alternative code but you should probably be looking at using CreateObject and using Object for the data type for Ie.
 
Upvote 0
If you go with Norie's suggestion, some of your code will have to be changed. For example:

Ie.readyState = READYSTATE_COMPLETE

probably won't run, you will have to lookup the true numeric value behind READYSTATE_COMPLETE (using object explorer) and use that instead.

Have you gone through all the references in the Tools menu of VBE? You really don't have one called "Microsoft Internet Controls"?
 
Upvote 0
Originally I was using this:

Code:
Do
        If Ie.readyState = 4 Then
            Ie.Visible = True
            Exit Do
        Else
            DoEvents
        End If
    Loop
 
Upvote 0
Yep, that's how you have to code if you use late-binding.

But, as long as you have IE installed on your computer, I would think the reference should be available to you to install. You've gone through all your VBE references and don't see it?
 
Upvote 0

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
Back
Top