Suppose you have a large research article or thesis in word document format which may have hundreds of pages. As part of editing, you want to check if there are duplicate paragraphs and then highlight to make them outstanding, so that you can deal with the duplicate sentences.
To do the same, we use a VBA (Microsoft Visual Basic for Applications window) code.
- For activating VBA code in Microsoft word. Open your desired word file and press Alt+F11 in your keyboard. Thus will open the VBA window.
- Click Insert > Module. This will open another window.
- Copy and paste below code into the opened blank module
Sub highlightdup()
Dim I, J As Long
Dim xRngFind, xRng As Range
Dim xStrFind, xStr As String
Options.DefaultHighlightColorIndex = wdYellow
Application.ScreenUpdating = False
With ActiveDocument
For I = 1 To .Paragraphs.Count - 1
Set xRngFind = .Paragraphs(I).Range
If xRngFind.HighlightColorIndex <> wdYellow Then
For J = I + 1 To .Paragraphs.Count
Set xRng = .Paragraphs(J).Range
If xRngFind.Text = xRng.Text Then
xRngFind.HighlightColorIndex = wdBrightGreen
xRng.HighlightColorIndex = wdYellow
End If
Next
End If
Next
End With
End Sub
- Now, press F5 key to run this code, all the duplicate sentences are highlighted at once, the first displayed duplicate paragraphs are highlighted with green color, and other duplicates are highlighted with yellow color.
Follow us on : www.biolit.in