共用方式為


DocumentBase.Merge Method

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)

Syntax

'Declaration
Public Sub Merge ( _
    fileName As String, _
    ByRef mergeTarget As Object, _
    ByRef detectFormatChanges As Object, _
    ByRef useFormattingFrom As Object, _
    ByRef addToRecentFiles As Object _
)
public void Merge(
    string fileName,
    ref Object mergeTarget,
    ref Object detectFormatChanges,
    ref Object useFormattingFrom,
    ref Object addToRecentFiles
)

Parameters

  • fileName
    Type: System.String

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

  • detectFormatChanges
    Type: System.Object%

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

  • addToRecentFiles
    Type: System.Object%

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

Remarks

Optional Parameters

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

Examples

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 Sub DocumentMerge()
    Me.Merge("C:\Docs\Sales2.docx", _
        MergeTarget:=Word.WdMergeTarget.wdMergeTargetCurrent, _
        DetectFormatChanges:=True, _
        UseFormattingFrom:=Word.WdUseFormattingFrom.wdFormattingFromCurrent, _
        AddToRecentFiles:=True)
End Sub
private void DocumentMerge()
{
    object MergeTarget = Word.WdMergeTarget.wdMergeTargetCurrent;
    object DetectFormatChanges = true;
    object UseFormattingFrom = 
        Word.WdUseFormattingFrom.wdFormattingFromCurrent;
    object AddToRecentFiles = true;

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

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace