|
请将代码复制到新建文档,再全选,剪切,到 VBE 中执行即可。
- Sub a_710_test()
- Dim t As Table
- For Each t In ActiveDocument.Tables
- With t
- If .Range.Cells(2).Range Like "选项*" Then
- .Range.Cells(2).Range.Text = "项目"
- .Range.Cells(4).Range.Text = "所占比例(%)"
- .Range.Font.ColorIndex = wdBlue
- .Range.Cells(5).Select
- With Selection
- .MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
- .Cells.Split NumRows:=5, NumColumns:=2, MergeBeforeSplit:=True
- .Delete Unit:=wdCharacter, Count:=1
- .MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
- .Cells.Merge
- .Cells(1).Range.Text = "选项"
- End With
- End If
- With .Range
- .Cells(6).Range.Text = "A"
- .Cells(9).Range.Text = "B"
- .Cells(12).Range.Text = "C"
- .Cells(15).Range.Text = "D"
- .Cells(18).Range.Text = "总计"
- End With
- .LeftPadding = CentimetersToPoints(0.19)
- .RightPadding = CentimetersToPoints(0.19)
- .AutoFitBehavior (wdAutoFitContent)
- .Select
- .AutoFitBehavior (wdAutoFitWindow)
- End With
- Next
- End Sub
复制代码 |
|