word表格中的单元格可以合并。
在vba中如果要合并word单元格,可以使用Cell对象的Merge方法。
其中Cell对象的Merge方法的语法如下:
object.Merge (MergeTo)
其中MergeTo参数为要合并的单元格区域的右下角单元格对象,而object对象为要合并的单元格区域的左上角单元格对象。
比如如下的代码将合并word表格中的第一个单元格和第二行第5列为结尾的单元格区域:
Sub exceloffice()
'作者QQ:1722187970,微信:xycgenius,微信公众号exceloffice
Dim oDoc As Document
Set oDoc = Word.ActiveDocument
Dim oT As Table
Dim oRow As Row
Dim oColumn As Column
Dim oCell As Cell
With oDoc
Set oT = .Tables(1)
With oT
.Cell(1, 1).Merge .Cell(2, 5)
End With
End With
End Sub
除了使用上述方法,还可以用Selection对象的Cells对象直接合并已经选中的单元格区域。


行列单元格申明变量纯属多余
谢谢水星大佬
还有个方案可以合并多个单元格
ActiveDocument.Range( OT.Cell(1, 1).Range.Start, OT.Cell(1, 4).Range.End).Cells.Merge