title: VBA access remote website, automate clicking submit after already automating clicking button on other webpage
body: <p>I'm working with vba in excel 2010 and internet explorer 8 and Vista.  The code below works to go to a remote website and post a form.  On the resulting page, the code should click the "get estimates" button.  Instead I get this error "object variable or with block variable not set".  The highlighted problem line in the code is "estimate = ieApp.document.getElementById("btnRequestEstimates")".  </p>
  
  <p>I think part of the problem might be that the button that isn't working is a submit button that isn't part of a form.  I am also wondering if the variables need to be reset before the 2nd button click.  The error message implies this is a qualification problem, but I think it's a pretty standard way of qualifying an element in this situation.  Those are some things I've been googling to no avail, I'm not really sure what the problem is.</p>
  
  <pre><code>Sub btn_version()
  
  Dim ieApp As Object
  Dim ieDoc As Object
  Dim ieForm As Object
  Dim ieObj As Object
  Dim URL As String
  Dim estimate As Object
  
  URL = "http://www.craft-e-corner.com/p-2688-new-testament-cricut-cartridge.aspx"
  Set ieApp = CreateObject("InternetExplorer.Application")
  ieApp.Visible = True
  ieApp.navigate URL
  While ieApp.Busy Or ieApp.readyState &lt;&gt; 4: DoEvents: Wend
  
  Set ieDoc = ieApp.document
  Set ieForm = ieDoc.forms(1)
  For Each ieObj In ieForm.Elements
  If ieObj.ClassName = "AddToCartButton" Then
  ieObj.Click
  End If
  Next ieObj
  
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  While ieApp.Busy Or ieApp.readyState &lt;&gt; 4: DoEvents: Wend
  estimate = ieApp.document.getElementById("btnRequestEstimates")
  estimate.submit
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  
  End Sub
  </code></pre>