DocumentBase.Compare Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Displays revision marks that indicate where the document differs from another document.
public void Compare (string name, ref object authorName, ref object compareTarget, ref object detectFormatChanges, ref object ignoreAllComparisonWarnings, ref object addToRecentFiles, ref object removePersonalInformation, ref object removeDateAndTime);
member this.Compare : string * obj * obj * obj * obj * obj * obj * obj -> unit
Public Sub Compare (name As String, Optional ByRef authorName As Object, Optional ByRef compareTarget As Object, Optional ByRef detectFormatChanges As Object, Optional ByRef ignoreAllComparisonWarnings As Object, Optional ByRef addToRecentFiles As Object, Optional ByRef removePersonalInformation As Object, Optional ByRef removeDateAndTime As Object)
Parameters
- name
- String
The name of the document with which the document is compared.
- authorName
- Object
The reviewer name associated with the differences generated by the comparison. If unspecified, the value defaults to the author name of the revised document or the string "Comparison" if no author information is present.
- compareTarget
- Object
The target document for the comparison. Can be any WdCompareTarget value.
- detectFormatChanges
- Object
true
(default) for the comparison to include detection of format changes.
- ignoreAllComparisonWarnings
- Object
true
compares the documents without notifying a user of problems. The default value is false
.
- addToRecentFiles
- Object
true
adds the document to the list of recently used files on the File menu.
- removePersonalInformation
- Object
true
if personal information should be removed from the specified document. The default value is false
.
- removeDateAndTime
- Object
true
removes date and time stamp information from tracked changes; false does not remove date and time stamp information from tracked changes.
Examples
The following code example uses the Compare method to compare the current document with the specified document and display revision marks to indicate where the documents differ. This example assumes that the file Sales1.docx exists on the current computer at the location C:\Docs. To use this example, run it from the ThisDocument
class in a document-level project.
private void DocumentCompare()
{
object compareTarget = Word.WdCompareTarget.wdCompareTargetNew;
object addToRecentFiles = false;
this.Compare("C:\\Docs\\Sales1.docx", ref missing, ref compareTarget,
ref missing, ref missing, ref addToRecentFiles, ref missing,
ref missing);
}
Private Sub DocumentCompare()
Me.Compare("C:\Docs\Sales1.docx", _
CompareTarget:=Word.WdCompareTarget.wdCompareTargetNew, _
AddToRecentFiles:=False)
End Sub
Remarks
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.