Option Compare Binary
Sub AlleWorteListen()
Dim i As Integer, k As Integer
Dim Anz As Integer, AnzW As Integer, AnzW2 As Integer
Dim aWorte(), aWorte2()
Dim Wort As String
Dim newDoc As Document
Dim found As Boolean
Anz = ActiveDocument.Words.Count
ReDim aWorte(Anz, 2)
If Anz > 0 Then
For i = 1 To Anz
found = False
Wort = ActiveDocument.Words(i)
If Len(Wort) > 1 Then
For k = 1 To i
If aWorte(k, 1) = Wort Then
found = True
AnzW = IIf(aWorte(k, 2) = Null, 0, aWorte(k, 2))
aWorte(k, 2) = AnzW + 1
End If
Next k
If Not found Then
aWorte(i, 1) = Wort
aWorte(i, 2) = 1
End If
End If
Next i
End If
'Jetzt die leeren Zeile entfernen
AnzW2 = 0
For i = 1 To UBound(aWorte)
If Len(Trim(aWorte(i, 1))) > 0 Then AnzW2 = AnzW2 + 1
Next i
ReDim aWorte2(AnzW2, 2)
k = 0
For i = 1 To UBound(aWorte)
If Len(Trim(aWorte(i, 1))) > 0 Then
k = k + 1
aWorte2(k, 1) = aWorte(i, 1)
aWorte2(k, 2) = aWorte(i, 2)
End If
Next i
Set newDoc = Documents.Add
For i = 1 To UBound(aWorte2)
newDoc.Content.InsertAfter aWorte2(i, 1) & Chr(9) _
& "Vorkommen: " & aWorte2(i, 2) & " Mal" & Chr(13)
Next i
newDoc.Content.Sort SortOrder:=wdSortOrderAscending
With Selection
.WholeStory
.ParagraphFormat.TabStops.ClearAll
.ParagraphFormat.TabStops.Add _
Position:=CentimetersToPoints(6), _
Alignment:=wdAlignTabLeft, _
Leader:=wdTabLeaderDots
.HomeKey Unit:=wdStory
End With
End Sub