title: Visual Basic User-defined type not defined
body: <p>I'm using VBA with excel to open certain web pages and if an IDelement is found save the page number to an Excel cell but I keep getting compile error: User-defined type not defined</p>
  
  <p>Sub PullMoh()</p>
  
  <pre><code>Dim IE  As Object
  Dim doc As HTMLDocument
  Dim ws  As Worksheet: Set ws = ThisWorkbook.Sheets("sheet1")
  Dim pn     'page number
  Dim mypage 'The default page
  Dim RowCount
  
  'Start at row number #
  RowCount = 2
  
  For pn = 342542 To 343235
      x = 1
      Set IE = CreateObject("InternetExplorer.Application")
      IE.Visible = True
      mypage = "https://" &amp; pn &amp; "/edit/320189/320225"
      IE.Navigate mypage
  
      Do While IE.Busy Or IE.ReadyState &lt;&gt; 4
          Application.Wait DateAdd("s", 1, Now)
      Loop
  
      Set doc = IE.Document
  
      'If webpage invalid make x = 0
      On Error Resume Next
      IsNull (doc.getElementById("edit-field-north-side-und-0-value").Value)
      If Err.Number &lt;&gt; 0 Then
          x = 0
      End If
  
      'Create if statement to check the element
      If x &lt;&gt; 0 Then
          ws.Range("A" &amp; RowCount) = pn
          ws.Range("B" &amp; RowCount).Value = doc.getElementById("edit-field-unit-no-und-0-value").Value    'Get unit number
          ws.Range("C" &amp; RowCount).Value = doc.getElementById("edit-field-floor-no-und-0-value").Value   'Get Level number
          ws.Range("D" &amp; RowCount).Value = doc.getElementById("edit-field-zooning-section-und").Value    'Get Division number
          ws.Range("E" &amp; RowCount).Value = doc.getElementById("edit-field-north-side-und-0-value").Value 'Get North
          ws.Range("F" &amp; RowCount).Value = doc.getElementById("edit-field-east-side-und-0-value").Value  'Get East
          ws.Range("G" &amp; RowCount).Value = doc.getElementById("edit-field-south-side-und-0-value").Value 'Get South
          ws.Range("H" &amp; RowCount).Value = doc.getElementById("edit-field-west-side-und-0-value").Value  'Get West
          ws.Range("I" &amp; RowCount).Value = doc.getElementById("edit-field-unit-area-und-0-value").Value  'Get Unit Area
          RowCount = RowCount + 1
      End If
  
      IE.Quit
  
  Next
  </code></pre>
  
  <p>End Sub</p>