提示:其他語言是Google翻譯的。 你可以訪問 English 版本。
登入
x
or
x
x
註冊
x

or

如何查找和突出顯示Word文檔中的重複段落?

假設你有一個可能有數百個頁面的大型Word文檔,現在,你想要檢查是否有重複的段落,然後突出顯示它們是否突出,以便你可以處理重複的句子。 如何在Word文檔中快速輕鬆地找到並突出顯示重複的段落?

使用VBA代碼查找並突出顯示Word文檔中的重複段落


使用VBA代碼查找並突出顯示Word文檔中的重複段落

若要查找並突出顯示Word文檔中的重複段落,以下VBA代碼可以幫到您,請執行以下操作:

1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。

2。 然後點擊 插入 > 模塊,將下面的代碼複製並粘貼到打開的空白模塊中:

VBA代碼:查找並突出顯示Word文檔中的重複段落:

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

3。 然後按 F5 運行此代碼的關鍵,所有重複的句子一次突出顯示,第一個顯示的重複段落用綠色突出顯示,其他重複段用黃色突出顯示,請參見屏幕截圖:

doc highlight重複句子1



推薦的Word生產力工具

Kutools For Word - 超過100 Word的高級功能,節省您的50%時間

  • 複雜和重複的操作可以在幾秒鐘內完成一次性處理。
  • 一次將多個圖像跨文件夾插入Word文檔。
  • 將多個文件夾合併並組合成一個具有所需訂單的文件。
  • 根據標題,分節符或其他標準將當前文檔拆分為單獨的文檔。
  • 在Doc和Docx,Docx和PDF之間轉換文件,用於常見轉換和選擇的工具集合等等......
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Alex · 1 months ago
    It throws Compile error: Syntax error, the code is 100% as the example.
  • To post as a guest, your comment is unpublished.
    dvid · 11 months ago
    I tried, and it works fine!
    I just wanted to know - could I do the same thing - but not a whole paragraph, but a sentence with a few words I'd set up - like 10 words?
  • To post as a guest, your comment is unpublished.
    Juliana · 11 months ago
    Tentei e não funcionou, só da que parou de funcionar.