title: The specified value is out of range
body: <p>I am trying to display slide no. in immediate window if they even one text box with a red font word. But the following error keeps popping up. Any ideas how I can go ahead.</p>
  
  <p>Run-time error'-2147024809(80070057)
  The specified value is out of range.</p>
  
  <p>Code:</p>
  
  <pre><code>Sub redfont()
  
      Dim sld As Slide
      Dim shp As Shape
      Dim x As Byte
      Dim z, i
  
      With ActivePresentation
          z = .Slides(.Slides.Count).SlideNumber
          MsgBox z, vbDefaultButton1, "Total Slides"
      End With
  
      Dim myCol As Collection
      Set myCol = New Collection
  
      For i = 2 To z
          Set sld = ActivePresentation.Slides(i)
          For Each shp In sld.Shapes
              If x = 1 Then
              x = 1
              ElseIf shp.TextFrame.TextRange.Font.Color.RGB = RGB(255, 0, 0) Then
                  myCol.Add CStr(i), CStr(i)
                  x = 1
              End If
          Next shp
          x = 0
      Next
  
      Dim j As Long
      For j = 1 To myCol.Count
          Debug.Print myCol.Item(j)
      Next j
  
  End Sub
  </code></pre>