|
* 请将代码复制并粘贴到空白文档中,再全选,剪切,粘贴到 VBE 中,以防乱码!
- Sub TableProcess()
- '表格处理
- Dim t As Table, c As Cell, i As Paragraph, a&
- With Selection
- If .Information(12) Then a = 1
- For Each t In ActiveDocument.Tables
- If a = 1 Then Set t = .Tables(1)
- With t
- '行高(最小值)
- With .Rows
- .HeightRule = wdRowHeightAtLeast
- .Height = CentimetersToPoints(0.9)
- End With
- With .Range
- '清除格式
- .Next.InsertParagraphBefore
- .MoveEnd
- .Select
- Selection.ClearFormatting
- If .Previous(4, 1).Font.Size = 16 Then .Font.Size = 12
- If .Previous(4, 1).Font.Size = 20 Then .Font.Size = 12
- CommandBars.FindControl(ID:=122).Execute
- .Characters.Last.Delete
- .Cells.VerticalAlignment = wdCellAlignVerticalCenter
- '删除空段
- For Each c In .Cells
- With c.Range
- For Each i In .Paragraphs
- With i.Range
- If Asc(.Text) = 13 And Len(.Text) = 1 Then .Delete
- End With
- Next
- With .Paragraphs
- If .Count > 1 And Len(.Last.Range) = 2 Then .Last.Previous.Range.Characters.Last.Delete
- End With
- End With
- Next
- End With
- '表头加粗
- .Cell(1, 1).Select
- With Selection
- .SelectRow
- With .Font
- .NameFarEast = "黑体"
- .Bold = True
- End With
- .Range.Find.Execute "[ ^s^t]", , , 1, , , , , , "", 2
- End With
- .LeftPadding = CentimetersToPoints(0.19)
- .RightPadding = CentimetersToPoints(0.19)
- .AutoFitBehavior (wdAutoFitContent)
- .Select
- .AutoFitBehavior (wdAutoFitWindow)
- End With
- If a = 1 Then Exit For
- Next
- End With
- End Sub
复制代码 |
|