|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
* 楼主,请将代码复制到空白文档中,全选,剪切,再粘贴到 VBE 中,否则可能有乱码。
Sub a0807_TableProcess_Test()
'表格处理
Dim t As Table, c As Cell, i As Paragraph, a&
For Each t In ActiveDocument.Tables
With t
'取消环绕/左对齐/左缩进/行高(最小值)
With .Rows
.WrapAroundText = False
.Alignment = wdAlignRowLeft
.LeftIndent = CentimetersToPoints(0)
.HeightRule = wdRowHeightAtLeast
.Height = CentimetersToPoints(0.9)
End With
'清除格式
With .Range
.Next.InsertParagraphBefore
.MoveEnd
.Select
Selection.ClearFormatting
CommandBars.FindControl(ID:=122).Execute
.MoveEnd 1, -1
.Next.Delete
With .Font
.NameFarEast = "宋体"
.NameAscii = "Times New Roman"
.Color = wdColorBlue
.Kerning = 0
.DisableCharacterSpaceGrid = True
End With
With .ParagraphFormat
.AutoAdjustRightIndent = False
.DisableLineHeightGrid = True
End With
.Cells.VerticalAlignment = wdCellAlignVerticalCenter
End With
'删除空段
For Each c In .Range.Cells
For Each i In c.Range.Paragraphs
If Asc(i.Range) = 13 And Len(i.Range) = 1 Then i.Range.Delete
Next
With c.Range.Paragraphs
If .Count > 1 And Len(.Last.Range) = 2 Then .Last.Previous.Range.Characters.Last.Delete
End With
Next
'表头加粗
.Cell(1, 1).Select
With Selection
.SelectRow
With .Font
.NameFarEast = "黑体"
.Bold = True
.Color = wdColorPink
End With
.Range.Find.Execute "[ ^s^t]", , , 1, , , , , , "", 2
End With
.LeftPadding = CentimetersToPoints(0.19)
.RightPadding = CentimetersToPoints(0.19)
.AutoFitBehavior (wdAutoFitContent)
.Select
.AutoFitBehavior (wdAutoFitWindow)
' .Range.Font.ColorIndex = wdAuto '自动色
End With
Next
Selection.HomeKey Unit:=wdStory
End Sub |
评分
-
2
查看全部评分
-
|