DocumentBase.Merge Method (String, Object, Object, Object, Object)


Merges the changes marked with revision marks from one document to another.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public void Merge(
	string fileName,
	ref object mergeTarget,
	ref object detectFormatChanges,
	ref object useFormattingFrom,
	ref object addToRecentFiles


Type: System.String

The name of the new file that includes the merged contents.

Type: System.Object

One of the T:Microsoft.Office.Interop.Word.WdMergeTarget values.

Type: System.Object

true to detect format changes in the document; otherwise, false.

Type: System.Object

One of the T:Microsoft.Office.Interop.Word.WdUseFormattingFrom values.

Type: System.Object

true to add to the recent files list; otherwise, false.

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the Merge method to merge the changes marked with revision marks in Sales2.docx into the document associated with the current project. This example assumes that the file Sales2.docx exists on the current computer in the folder C:\Docs. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentMerge()
    object MergeTarget = Word.WdMergeTarget.wdMergeTargetCurrent;
    object DetectFormatChanges = true;
    object UseFormattingFrom = 
    object AddToRecentFiles = true;

    this.Merge("C:\\Docs\\Sales2.docx", ref MergeTarget,
        ref DetectFormatChanges, ref UseFormattingFrom, 
        ref AddToRecentFiles);
Return to top