title: Use VBA to Fill Textbox and Click Button on Webpage
body: <p>I'm trying to use VBA to excess a webpage. What I want to do is to fill a textbox with my own inputs and then proceed to the search result by pressing the search button.</p>
  
  <p>Here's the link of the webpage: <a href="http://www.sec.gov/edgar/searchedgar/companysearch.html" rel="nofollow">http://www.sec.gov/edgar/searchedgar/companysearch.html</a></p>
  
  <p>On the right side of the page, under "Fast Search", there is a box that I can put in a stock ticker or a CIK code, and if I type in "AAPL" and click the "search" button right by the textbox, I will be able to see some information regarding the company Apple.</p>
  
  <p>Here's the code I've written:</p>
  
  <pre><code>Option Explicit
  Const url = "http://www.sec.gov/edgar/searchedgar/companysearch.html"
  
  Sub Test2()
  Dim ie As Object
  
  Set ie = CreateObject("InternetExplorer.Application")
  ie.Navigate url
  
  Do While ie.ReadyState &lt;&gt; 4
    DoEvents
  Loop
  ie.Visible = True
  
  With ie.Document
    .GetElementById("cik").Value = "AAPL"
    .GetElementById("search_button_2").Click
  End With
  End Sub
  </code></pre>
  
  <p>Using it I am able to put "AAPL" into the textbox. But when I run the code, IE will direct me to an error page, telling me it's unable to recognize the ticker I put in. I am fairly certain the ID for the search button is "search_button_2". However I am fairly new to HTML, so I am kind of stuck at the last step. </p>
  
  <p>Thank you guys so much for helping me out. I'd appreciate any solution or suggestion.</p>