如何用vba删除word表格中的行列?

在vba中,Row对象表示word表格的行,Column对象表示word表格的列。

要删除word表格行、列只需使用对应的Delete方法即可。

代码如下:

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
                Set oRow = .Rows(7)
                oRow.Delete
                Set oColumn = .Columns(3)
                oColumn.Delete
            End With
    End With
End Sub
       

发表评论