IE and VBA .submit not working

drmingle

Board Regular
Joined
Oct 5, 2009
Messages
229
Everything works fine with this code...,but the last piece.

Code:
IE.Document.forms(0).submit
It's not selecting the proper HTML button.

I have included the HTML source code to identify tags:


HTML:

Below is the full routine:

Code:
Sub NPIRegistry()
    Dim IE
    Set IE = CreateObject("InternetExplorer.application")
    IE.Visible = True
    IE.navigate ("https://nppes.cms.hhs.gov/NPPES/NPIRegistrySearch.do?subAction=reset&searchType=ind")
    Do
        If IE.readyState = 4 Then
            IE.Visible = True
            Exit Do
        Else
            DoEvents
        End If
    Loop
      'USE VIEW SOURCE TO GET FORM ELEMENT IDS
    IE.Document.forms(0).all("searchNpi").Value = Range("I10")
    IE.Document.forms(0).all("firstName").Value = Range("I8")
    IE.Document.forms(0).all("lastName").Value = Range("I9")
    IE.Document.forms(0).all("state").Value = Range("I13")
    IE.Document.forms(0).submit
End Sub
What should pull up are search results for a doctor...I just get a page asking for me to call the web administrator.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Your code worked fine for me. Are you certain that your values are valid? Try this alternative method of submitting the form and see if that makes any difference...

Replace:
IE.Document.forms(0).submit

With:
IE.Document.getelementsbyname("subAction")(0).Click

Have a nice day! Tom :)
 
Upvote 0
Tom, you are a genius... I´ve been trying for weeks a similar issue until i found your post/answer.

Question: why "button(0).Click" have to take "(0)" parameter? where I can find more info about that

regards
 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,269
Members
449,093
Latest member
Vincent Khandagale

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