1

I cannot seem to submit the click the submit or go button. It seems to be under a javascript which I am not sure how to enter a code to click the go button. Here is what I have:

Sub FactFinderForm()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
IE.Navigate "http://factfinder.census.gov/faces/nav/jsf/pages/index.xhtml###"
'go to web page listed inside quotes
IE.Visible = True

While IE.busy
DoEvents 'wait until IE is done loading page.
Wend

IE.Document.getElementsByname("cfsearchtextboxmain").Item.innertext = _
              ThisWorkbook.Sheets("sheet1").Range("a1")

While IE.readyState <> 4
DoEvents
Wend

SendKeys "{enter}"

End Sub

2 Answers 2

1

Try this:

With IE.Document

    .getElementById("cfsearchtextboxmain").Value = _
          ThisWorkbook.Sheets("sheet1").Range("a1").Value

    .parentWindow.ExecScript "cfMainFormSubmit()"

End With
Sign up to request clarification or add additional context in comments.

Comments

1

You could also have used a css selector to target the element.

#cfmainsearchform > a

That says a tag within element with id cfmainsearchform. # is id and > within (child combinator).

ie.document.querySelector("#cfmainsearchform > a").Click

Comments

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.