在word 表格中可以插入行列。
如果要用vba给word表格插入行或者列,可以使用如下的代码:
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
With oDoc
Set oT = .Tables(1)
With oT
'设置要在第几行前面插入行,这里是第2行
Set oRow = .Rows(2)
'在第2行前面插入行
.Rows.Add oRow
Set oColumn = .Columns(3)
'在第3列左边插入一个空列
.Columns.Add oColumn
End With
End With
End Sub
其中Rows.Add方法和Columns.Add后面必须带具体的某行或某列对象。


发表评论