Word中使用宏调整表格

Dim i As Integer
 
For i = 1 To Selection.Tables.Count
    Selection.Tables(i).Columns(9).Delete
    Selection.Tables(i).AutoFitBehavior (wdAutoFitContent)
    Selection.Tables(i).AutoFitBehavior (wdAutoFitContent)
    Next
End Sub

        上面宏的作用是遍历选中内容中的所有表格,把所有表格的第9列删掉,然后设置表格属性,使其“按照内容进行自动调整”
有两点需要注意,一是宏中遍历时都是从1开始的,而不是0;二是,一旦开始录制宏的时候,不能选中,不能有右键菜单,只能通过工具栏来操作

原文地址:https://www.cnblogs.com/xiaoxiangfeizi/p/3495652.html