|
本帖最后由 woyaofacai 于 2015-12-2 10:37 编辑
借用大神的代码,能否加入自动判断文字就靠左对齐,数字就靠右对齐呢?
WORD格式排版.rar
(15.54 KB, 下载次数: 14)
如附件中的批注
Sub 表格处理()
On Error Resume Next
Dim t As Table, n As Long
If Selection.Information(wdWithInTable) = True Then Selection.Tables(1).Select: n = 1
For Each t In ActiveDocument.Tables
If n = 1 Then Set t = Selection.Tables(1) Else t.Select
With t.Rows
.WrapAroundText = False
.Alignment = wdAlignRowLeft
.HeightRule = wdRowHeightAtLeast
.Height = CentimetersToPoints(0.65)
End With
With t.Range
.Font.Name = "宋体"
.Font.Name = "Times New Roman"
.Font.Size = 10.5
With .Cells
.DistributeWidth
.VerticalAlignment = wdCellAlignVerticalCenter
End With
With .ParagraphFormat
.Alignment = wdAlignParagraphCenter
.CharacterUnitFirstLineIndent = 0
.FirstLineIndent = CentimetersToPoints(0)
.Space1
End With
End With
With Selection.Tables(1)
.TopPadding = CentimetersToPoints(0)
.BottomPadding = CentimetersToPoints(0)
.LeftPadding = CentimetersToPoints(0)
.RightPadding = CentimetersToPoints(0)
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = True
End With
Next
End Sub
|
|