title: How to iterate through text in the Word document by VB macro
body: <p>I wanted to count chars in the Word document by Macro I have no idea how to get reference two the text in visual basic macro and go through it.</p>
  
  <p>I would like to count how many of every char was in the document.
  For example in document: </p>
  
  <pre><code>ABZBB
  </code></pre>
  
  <hr>
  
  <pre><code>A x 1
  B x 3
  Z x 1
  
     Sub Macro1()
  Dim Box As Shape
  Set Box = ActiveDocument.Shapes.AddTextbox( _
  Orientation:=msoTextOrientationHorizontal, _
  Left:=50, Top:=50, Width:=200, Height:=400)
  Box.TextFrame.TextRange.Text = "My text comes this way" + Chr(10)
  Dim s As String
  Application.ScreenUpdating = False
  docLength = ActiveDocument.Range.Characters.Count
  
  Box.TextFrame.TextRange.Text = Box.TextFrame.TextRange.Text + "Text length is: " + Str(docLength) + Chr(10)
  
  Dim arr(128) As Integer
  Dim character As Integer
  For i = 1 To docLength - 1
  
          character = Asc(ActiveDocument.Range.Characters(i))
  If iAsc &gt;= 0 And iAsc &lt;= 127 Then
           arr(character) = arr(character) + 1
   End If
  Next i
  
  
  End Sub
  </code></pre>