请问word中多表格如何批量调整格式?

解决方案 »

  1.   

    首先,录制宏,选择一个表格,把你对单个表格做的事情都用录下来。
    然后看生成的代码。基本都是对selection对象的一系列操作。
    就像下面这个一样
    Sub 宏4()
    '
    ' 宏4 宏
    '
    '
        Selection.MoveUp Unit:=wdLine, Count:=4, Extend:=wdExtend
        Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.Shading.Texture = wdTextureNone
        Selection.Shading.ForegroundPatternColor = wdColorAutomatic
        Selection.Shading.BackgroundPatternColor = -553582746
        Selection.Font.Name = "黑体"
        Selection.Tables(1).Style = "网格型浅色"
    End Sub
    接下来,写自己的宏,总体的思路就是遍历文档中左右的表格,然后把每个表格选中,再重复对单个表格干的事情。Sub test()
        Dim t As Table
        For Each t In Application.ActiveDocument.Tables '遍历文档中所有表格
            t.Select '把表格选中        'TODO:把单个表格操作录制的宏代码贴上来即可
            
            DoEvents
        Next
    End Sub