How to click button on a webpage, using inspect

ExcelJWS

New Member
Joined
May 19, 2016
Messages
4
Hi guys,


I have made a program that will put addresses into the website Distance between two addresses, cities or zipcodes


But I don't know how to get excel to Click on the "calculate distance" button. I've looked on a bunch of youtube videos (which is why I'm able to put values into the 'from' and 'to' boxes. But am still unable to get it to click the button for me). It should be the last lane of code that needs to be changed to something else.



Code:
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")


    IE.navigate "http://www.mapdevelopers.com/distance_from_to.php"
    Do
    DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    IE.document.all("from").Value = Addy1.Value
    IE.document.all("to").Value = Addy2.Value
The code above puts the addresses into the website
the code below is my attempt to click on the "calculate distance button"
Code:
    IE.document.all("link_button").Click



Any advice would be awesome.


Thanks,


ExcelJWS
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
ExcelJWS,

Welcome to the MessageBoard!

Try this line of code. I just tested it... it works for me:

Code:
IE.document.forms(1).submit
 
Last edited:
Upvote 0
ExcelJWS,

Welcome to the MessageBoard!

Try this line of code. I just tested it... it works for me:

Code:
IE.document.forms(1).submit



Hey mrmmcikle1,

Do you have any ways of discovering what code you'll need for a particular button on a website or is it trial and error?
lets say you wanted you write something to click the reply button on this forum. After using "inspect" how would you go about discovering what code you need for the button?

Thanks
EXCELJWS
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,542
Members
449,169
Latest member
mm424

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