Recognize duplicate headings/chapters from Word document

337 views Asked by At

I have a big word document. Now I'm searching for a solution which can show me if there are duplicate chapters/headings. When one is found I want the name (and perhaps the page number). Later I want to delete the duplicate chapter by myself.

The heading has no numeration and is a stylesheet (Heading 1).

I thought a VBA script would do that, but I have never used it. How can one do that?

This is how I got so far:

Sub FindDuplicates()
    Dim DocPara As Paragraph
    Dim DocPara2 As Paragraph

    For Each DocPara In ActiveDocument.Paragraphs
        If Left(DocPara.Range.Style, Len("Überschrift 1")) = "Überschrift 1" Then
            For Each DocPara2 In ActiveDocument.Paragraphs
                If Left(DocPara.Range.Style, Len("Überschrift 1")) = "Überschrift 1" Then
                     Debug.Print DocPara.Range.Text
                End If
            Next
        End If
    Next
End Sub

But it never gets finished. Don't know if it's an error in my code or VBA isn't able to handle the amount of data (> 400 pages). Perhaps someone could help.

0

There are 0 answers