Merge Method
Applies To
Cell object, Cells collection object, Document object, Subdocuments collection object.
Description
Cell object: Merges the specified table cell with another cell. The result is a single table cell.
Cells object: Merges the specified table cells with one another. The result is a single table cell.
Document object: Merges the changes marked with revision marks from one document to another.
Subdocument object: Merges the specified subdocuments of a master document into a single subdocument.
Syntax 1
expression.Merge(MergeTo)
Syntax 2
expression.Merge
Syntax 3
expression.Merge(FileName)
Syntax 4
expression.Merge(FirstSubdocument, LastSubdocument)
expression Syntax 1: An expression that returns a Cell object.
Syntax 2: An expression that returns a Cells object.
Syntax 3: An expression that returns a Document object.
Syntax 4: An expression that returns a Subdocuments object.
MergeTo Required Cell. The cell to be merged with.
FileName Required String. The path and file name of the original document you want to merge revisions with.
FirstSubdocument Optional Variant. The first subdocument in a range of subdocuments to be merged.
LastSubdocument Optional Variant. The last subdocument in a range of subdocuments to be merged.
See Also
Compare method, Revisions property, Split method.
Example
This example merges the first two cells in table one in the active document with one another and then removes the table borders.
If ActiveDocument.Tables.Count >= 1 Then
With ActiveDocument.Tables(1)
.Cell(Row:=1, Column:=1).Merge MergeTo:=.Cell(Row:=1, Column:=2)
.Borders.Enable = False
End With
End If
This example merges changes from Sales2.doc (the active document) into Sales1.doc.
If InStr(1, ActiveDocument.Name, "sales2.doc", 1) Then _
ActiveDocument.Merge FileName:="C:\Docs\Sales1.doc"
This example merges the cells in row one of the selection into a single cell and then applies shading to the row.
If Selection.Information(wdWithInTable) = True Then
Set myrow = Selection.Rows(1)
myrow.Cells.Merge
myrow.Shading.Texture = wdTexture10Percent
End If
This example merges the first and second subdocuments in the active document into one subdocument.
If ActiveDocument.Subdocuments.Count >= 2 Then
Set aDoc = ActiveDocument
aDoc.Subdocuments.Merge FirstSubdocument:=aDoc.Subdocuments(1), _
LastSubdocument:=aDoc.Subdocuments(2)
End If