0

I have been trying without success to click this button on GPS Vizualizer, I have tried a couple of methods including after setting up my dims etc and setting to the document..; No success, what am I missing, can anyone help, thanks

With doc.all("input")
    .focus
    .OnClick
End With

HTML:

<input style="font-weight: bold; margin-bottom: 3px;" 
  onclick="this.form.action='http://www.gpsvisualizer.com/map?output_geocoder'; document.map_form.special.value='geocoder'; this.form.submit();" 
   type="button" value="Draw a map">
4
  • If there's only one button then use doc.getElementsByTagName(0) to refer to the button. If there are multiple buttons then loop over them until you find the one with Value "Draw a Map" Commented Jun 23, 2018 at 18:28
  • Thanks Tim, I have tried similar code to this and made other attempts following your reply without success, would you expand a little more on how you would achive this? Commented Jun 23, 2018 at 19:19
  • Sure - care to share a little more code though, including a URL ? Commented Jun 23, 2018 at 19:48
  • gps visualizer gpsvisualizer.com/geocoder Commented Jun 23, 2018 at 20:43

3 Answers 3

0

runtime error screen capture

Set doc = IE.Document
With doc
doc.getElementById("google_key_box").Value = "Api Key here"
doc.getElementById("geocode_input").focus
doc.getElementById("geocode_input").Value = retVal
End With
With doc.all("data_source")

                                .focus
                                .Value = "google"
                                .OnChange
                                End With
With doc.all("start")

                                .focus
                                .OnClick
                                End With

doc.querySelector("input[onclick*=this.form.action='http://www.gpsvisualizer.com/map? 
output_geocoder';]").Click
Sign up to request clarification or add additional context in comments.

1 Comment

The code sets a drop box so a google map is used followed by a button click to code coordinates, Your code would draw the map, thanks
0

Try:

.document.querySelector("input[onclick*='this.form.action']")

CSS query

It uses the .querySelector method of the document to apply a css selector which looks for input tag containing attribute onclick, which contains string 'this.form.action'

You can also use:

doc.getElementsByTagName("input")(8).Click

The following worked:

Option Explicit

Public Sub GetInfo()
    Dim IE As New InternetExplorer

    With IE
        .Visible = True
        .navigate "http://www.gpsvisualizer.com/geocoder/"

        While .Busy Or .readyState < 4: DoEvents: Wend
        .document.querySelector("input[onclick*='this.form.action']").Click
       ' .document.getElementsByTagName("input")(8).Click

       Stop '<==Delete me
        .Quit
    End With
End Sub

10 Comments

This is my code, it adds a recordset to apply input details and set a couple of items and output this to make the map. I have added QHarr's code but i get a runtime error.
Sorry that wasn't meant to go
yes, i have been doing this manually and it works great, I am working towards hiding iE and delivering the map as a downloa which certainly looks do-able
Thanks, I dont get the runtime error but it still wont click the darn button. If you have a moment can you inspect the page?
I have. The code I posted works. It clicks the button and the page changes. Both methods I listed I tested. It takes you to a draw map page.
|
0

Try this code. It should click on that button and open a new tab.

Sub ClickONButton()
    Const url As String = "http://www.gpsvisualizer.com/geocoder/"
    Dim IE As New InternetExplorer, Html As HTMLDocument, R&

    With IE
        .Visible = True
        .navigate url
        While .Busy = True Or .readyState < 4: DoEvents: Wend
        Set Html = .document
    End With
    Html.querySelector("input[value='Draw a map']").Click
End Sub

Reference to add to the library:

Microsoft Internet Controls
Microsoft HTML Object Library

1 Comment

I suppose you are using latest version of IE @GMan63.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.