title: type mismatch looping through shapes
body: <p>I'm getting a type mismatch 13 error in the line that loops through the shapes in a slide. I can see that the <code>oSh</code> is <code>Nothing</code>, but if I <code>.Count</code> the shapes, there are plenty of shapes in the slide. How does this make sense?</p>
  
  <p><strong>Brief code:</strong></p>
  
  <pre><code>Dim oPP As PowerPoint.Presentation
  Dim oS As Slide
  Dim oSh As Shape
  For Each oS In oPP.Slides
      For Each oSh In oS.Shapes '&lt;-- this line is the error line
          On Error Resume Next
          If oSh.Type = 14 _
                  Or oSh.Type = 1 Then
              'do stuff            
          End If
          On Error GoTo 0
      Next oSh
  Next oS
  </code></pre>
  
  <p><strong>Full code:</strong></p>
  
  <pre><code>Sub PPLateBinding()
      Dim pathString As String
      'no reference required
      Dim PowerPointApplication As PowerPoint.Application
      Dim oPP As PowerPoint.Presentation
      Dim oS As Slide
      Dim oSh As Object
      Dim pText As String
      Dim cellDest As Integer
      Dim arrBase() As Variant
      Dim arrComp() As Variant
      ReDim Preserve arrBase(1)
      ReDim Preserve arrComp(1)
  
      Dim fd As FileDialog
      Dim FileChosen As Integer
      Dim FileName As String
      Dim iPresentations As Integer
  
      Set fd = Application.FileDialog(msoFileDialogFilePicker)
      'use the standard title and filters, but change the
      fd.InitialView = msoFileDialogViewList
      'allow multiple file selection
      fd.AllowMultiSelect = True
  
      FileChosen = fd.Show
      If FileChosen = -1 Then
      'open each of the files chosen
      For iPresentations = 1 To fd.SelectedItems.Count
          'On Error Resume Next
          Set PowerPointApplication = CreateObject("PowerPoint.Application")
          Set oPP = PowerPointApplication.Presentations.Open(fd.SelectedItems(iPresentations))
          If Err.Number &lt;&gt; 0 Then
              Set oPP = Nothing
          End If
  
          If Not (oPP Is Nothing) Then
              cellDest = 0
  
              'We assume PP is already open and has an active presentation
              For Each oS In oPP.Slides
                  'Debug.Print oPP.Slides.Count
                  If oS.Shapes.Count &gt; 0 Then
                      Debug.Print oS.Shapes.Count
                          For Each oSh In oS.Shapes
                              Debug.Print "hey"
                              On Error Resume Next
                              If oSh.Type = 14 Or oSh.Type = 1 Then
                                  pText = oSh.TextFrame.TextRange.Text
                                  ReDim Preserve arrBase(UBound(arrBase) + 1)
                                  arrBase(UBound(arrBase)) = pText
                                      'Debug.Print pText
                              ElseIf (oSh.HasTable) Then
                                  Dim i As Integer
                                  For i = 2 To oSh.Table.Rows.Count
                                      ReDim Preserve arrComp(UBound(arrComp) + 1)
                                      arrComp(UBound(arrComp)) = Replace(oSh.Table.Cell(i, 1).Shape.TextFrame.TextRange.Text, vbLf, "") &amp; ":::" &amp; oSh.Table.Cell(i, 3).Shape.TextFrame.TextRange.Text
                                  Next i
                              End If
                              On Error GoTo 0
                          Next oSh
                      'x = InputData(arrBase, arrComp)
                  End If
              Next oS
  
              'Debug.Print tbl.Shape.TextFrame.TextRange.Text '.Cell(1, 1).Shape.TextRange.Text
              oPP.Close
              PowerPointApplication.Quit
              Set oPP = Nothing
              Set PowerPointApplication = Nothing
          End If
      Next iPresentations
      End If
  End Sub
  </code></pre>