Clicking a button via IE automation VBA

vba_newbie2013

New Member
Joined
Jun 18, 2013
Messages
29
Hey, i'm trying to click a submit/go button on a webpage and i cant seem to get it to work. Everything i've worked with so far seems to have an ID that works well with getElementById call, but with this button i cant seem to find anything that will reference to it and click. I've tried the following with no success:

getElementsByTagName("").Click/submit
getElementsByClassName("").Click/submit
getElementsByName("").Click /submit
getElementsById("").Click/submit

Here's the HTML code from the webpage i think what i need is located in, also following that is the actual webpage.


Code:
[COLOR=#800000]div[/COLOR][COLOR=#ff0000]class[/COLOR][COLOR=#0000ff]="go-btn-box">[/COLOR]
[COLOR=#0000ff]<[/COLOR][COLOR=#800000]input[/COLOR][COLOR=#ff0000]class[/COLOR][COLOR=#0000ff]="btn go-btn" [/COLOR][COLOR=#ff0000]alt[/COLOR][COLOR=#0000ff]="Get Individual & Family Health Insurance Quotes" [/COLOR][COLOR=#ff0000]title[/COLOR][COLOR=#0000ff]="Get Individual & Family Health Insurance Quotes" [/COLOR][COLOR=#ff0000]name[/COLOR][COLOR=#0000ff]="method:submit" [/COLOR][COLOR=#ff0000]type[/COLOR][COLOR=#0000ff]="image" [/COLOR][COLOR=#ff0000]*******[/COLOR][COLOR=#0000ff]="return shoppingCart.checkCensus($('#mainForm'), 'IFP', 'submit');" [/COLOR][COLOR=#ff0000]width[/COLOR][COLOR=#0000ff]="145" [/COLOR][COLOR=#ff0000]height[/COLOR][COLOR=#0000ff]="44" [/COLOR][COLOR=#ff0000]src[/COLOR][COLOR=#0000ff]="http://static.ehealthinsurance.com/ehealthinsurance/images_new/buttons/wide-census-go.gif" />[/COLOR]
[COLOR=#0000ff]</< font>[COLOR=#800000]div[/COLOR][COLOR=#0000ff]>[/COLOR]
[/COLOR]


Website: Individual and Family Health Insurance

Thanks for any help you can provide!
 
Look at the HTML you originally posted:
Code:
[COLOR=#0000ff]<[/COLOR][COLOR=#800000]input[/COLOR][COLOR=#ff0000] class[/COLOR][COLOR=#0000ff]="btn go-btn" [/COLOR][COLOR=#ff0000]alt[/COLOR][COLOR=#0000ff]="Get Individual & Family Health Insurance Quotes" [/COLOR][COLOR=#ff0000]title[/COLOR][COLOR=#0000ff]="Get Individual & Family Health Insurance Quotes[/COLOR]

It is an INPUT tag with the title "Get Individual & Family Health Insurance Quotes". So we want to loop through all input tags until we find the one with that title, then click it.

Code:
Set objInputs = IE.Document.getElementsByTagName("input")

Gets the collection of INPUT tags. THen we just loop through and check the .title property until we have a match.
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You haven't posted the code you are using or said how what you've tried hasn't work.

If the aim of the button click is to submit a form, and that form is the only one on the page, then you might want to try IE.document.forms(0).submit.

Thank you for this response Norie. You just saved my day, week, and month! Exactly what I needed to solve a ‘with block not set’ error when trying to re-click the search button after new terms are entered. I was close as it worked great on the first pass but after the second term was entered in the search box it would fail at the button click line.

Thanks again. I am so thankful for smart people like yourself! ?
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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