|
* 楼主,你自己将 .Height = xxxxxx(0.9) 这个 0.9 厘米 改小即可,如改为 0.5 或 0.6,请试用最新版本:
- Sub TableProcess_Update()
- '表格处理 -> 光标在表格外处理所有表格;否则当前表格(选定则选区表格)
- Dim r As Range, t As Table, c As Cell, i As Paragraph, a As Row, x&, y&, z&, j&, k&, e&, n&
- PaperSetup
- With ActiveDocument
- .Fields.Unlink
- .ConvertNumbersToText
- .Content.Find.Execute "^l", , , 0, , , , , , "^p", 2
- End With
- With Selection
- If .Type = wdSelectionIP Then
- If .Information(wdWithInTable) = True Then
- Set t = .Tables(1)
- Set r = .Tables(1).Range
- Else
- Set r = ActiveDocument.Content
- End If
- Else
- Set r = .Range
- End If
- End With
- For Each t In r.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
- CommandBars.FindControl(ID:=122).Execute
- Selection.ClearFormatting
- .MoveEnd 1, -1
- With .Font
- .Size = 12
- .Color = wdColorBlue
- .Kerning = 0
- .DisableCharacterSpaceGrid = True
- End With
- With .ParagraphFormat
- .Alignment = wdAlignParagraphCenter
- .AutoAdjustRightIndent = False
- .DisableLineHeightGrid = True
- End With
- .Cells.VerticalAlignment = wdCellAlignVerticalCenter
- .Next.Delete
- '判断表格是否规则(e=1=规则/e=0=不规则)
- x = .Information(wdEndOfRangeRowNumber)
- y = .Information(wdEndOfRangeColumnNumber)
- z = .Cells.Count
- End With
- If x <> 1 Then
- If z = x * y Then
- For k = 1 To y
- For j = 1 To x - 1
- If .Cell(j + 1, k).Width = .Cell(j, k).Width Then e = 1 Else e = 0
- If e = 0 Then Exit For
- Next j
- If e = 0 Then Exit For
- Next k
- Else
- e = 0
- End If
- Else
- e = 1
- End If
- '删除空段
- 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
- With .Range.Find
- .Execute "^w", , , 0, , , , , , "", 2
- .Execute " ", , , 0, , , , , , "", 2
- End With
- End With
- If e = 1 Then
- '删除序号
- If .Cell(1, 1).Range Like "序号*" Then
- ActiveDocument.Range(Start:=.Cell(2, 1).Range.Start, End:=.Cell(x, 1).Range.End).Delete
- End If
- '删除空行
- For Each a In .Rows
- If Len(Replace(Replace(a.Range.Text, vbCr, ""), Chr(7), "")) = 0 Then a.Delete
- Next
- '序号自动
- If .Cell(1, 1).Range Like "序号*" Then
- ActiveDocument.Range(Start:=.Cell(2, 1).Range.Start, End:=.Cell(x, 1).Range.End).Select
- n = 0
- For Each c In Selection.Cells
- n = n + 1
- c.Range.Text = n
- Next
- End If
- End If
- '边距
- .LeftPadding = CentimetersToPoints(0.19)
- .RightPadding = CentimetersToPoints(0.19)
- .AutoFitBehavior (wdAutoFitContent)
- .Select
- .AutoFitBehavior (wdAutoFitWindow)
- End With
- Next
- ' Selection.HomeKey Unit:=wdStory
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|