title: object required error in VBA
body: <p>I have a form that I created with 2 text input boxes and a submit button in excel.</p>
  
  <p>I need to basically take the data that the user input into my 2 form fields and then put it into cells in excel. </p>
  
  <p>Here is the code I have but for some reason I am getting an Object required error even though I set my variables.</p>
  
  <pre><code>Private Sub CommandButton1_Click()
      Dim startPoint As String, endPoint As String
  
      Set startPoint = ActiveDocument.FormFields("TextBox1").Result
          If startPoint = "" Then Exit Sub
              Worksheets(1).Range("A1").value = startPoint
      Set endPoint = ActiveDocument.FormFields("TextBox2").Result
          If endPoint1 = "" Then Exit Sub
              Worksheets(1).Range("A4").value = endPoint
  
      m1 = Worksheets(1).Range("D4").value
      km1 = m1 / 1000
      MsgBox "Your starting point is " &amp; startPoint &amp; vbCrLf _
          &amp; vbCrLf &amp; "It is " &amp; m1 &amp; "m" &amp; " (" &amp; km1 &amp; "km) from " &amp; endPoint
  
  End Sub
  </code></pre>