title: VBA Counting Shapes in Visio
body: <p>i want to count how many shapes of one type i have on my sheet and save it to a label.</p>
  
  <pre><code>Sub Counter()
  
  Dim shp As Visio.Shape
  Dim i As Integer
  
  For Each shp In ActivePage.Shapes
      If shp.Master.Name Like "DV-ED.*" Then
         i = i + 1
          End If
          ActivePage.Shapes("SheetED").Characters.Text = CStr(i)
  Next shp
  End Sub
  </code></pre>
  
  <p>Problem is, that after the last shape of that type i get an error</p>
  
  <blockquote>
    <p>"Run Time Error '91' : Object Variable or With Block not Set"</p>
  </blockquote>
  
  <p>im not very familiar with VBA</p>