比较三个或更多Word文档(* .docx)


0

我已经看到了如何比较两个Word文档的多个问题和答案,我已经看到了如何比较三个或更多原始文本文件的一些问题和答案,但我很难找到一个方法来比较三个或更多Word文档。

我不需要比较格式,我不介意我不能编辑或合并它们,但我希望能够看到文件的差异突出显示。我知道我可以将文本复制到文本文件中并在原始文本的diff工具中使用它,但是我需要比较的一些Word文档非常大。


您使用的是什么版本的Word?
Rich Michaels

@RichMichaels我正在使用Word 2010。
zarose

Answers:


0

我不知道如何在屏幕上并排比较两个以上的文档。

如果您有多个修订文档,则可以将它们合并为一个新文档,但您可能已经知道该功能。

如果您有多个修订文档,并且想要“自动化”该过程以减少您必须执行的某些手动输入,则可以使用如下所示的宏。

Sub CompareDocs()
    Dim doc As word.Document, iDoc As word.Document, rDoc As word.Document
    Dim selFiles() As String, strFolderPath As String
    Dim Sep As String, i As Long
    On Error GoTo errHandler

    Sep = Application.PathSeparator
    Set doc = ActiveDocument
    Application.ScreenUpdating = False
    With Application.FileDialog(msoFileDialogFilePicker)
        .Title = "Select the files to compare to your source document"
        .InitialFileName = curDir
        .AllowMultiSelect = True
        If .Show = 0 Then
            Exit Sub
        End If
        ReDim Preserve selFiles(.SelectedItems.Count - 1)
        strFolderPath = Left(.SelectedItems(1), InStrRev(.SelectedItems(1), Sep))
        For i = 0 To .SelectedItems.Count - 1
            selFiles(i) = .SelectedItems(i + 1)
        Next
    End With
    For i = 0 To UBound(selFiles)
        Set iDoc = Documents.Open(selFiles(i))
        Set rDoc = Application.CompareDocuments(OriginalDocument:=doc, RevisedDocument:=iDoc, _
        CompareFormatting:=False, CompareComments:=False)
        rDoc.SaveAs2 strFolderPath & "Compared_" & iDoc.Name
        rDoc.Close
        iDoc.Close
    Next
    Application.ScreenUpdating = True
    MsgBox "Document Compares Complete"
    Exit Sub
errHandler:
    MsgBox Err.Description, vbCritical, "Compare Docs"
    Err.Clear
    Application.ScreenUpdating = True
End Sub
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.