|
因此我们专业报告是由各专业的人编写再汇总,大家的表格编制格式都不一样,所以最后报告汇总时需调整所有的表格,工作量很大。我这个有别人的宏代码,它会自动处理表格,不过它处理的格式与我们的要求不太一样,还请大家帮我看看要怎么修改这段代码。表格处理前后的格式详见附件,若是可以连表格上面的表名和表格编号的格式也一起修改,那是最好。谢谢!
参考代码:
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
With .Rows
.WrapAroundText = False
.Alignment = wdAlignRowLeft
.HeightRule = wdRowHeightAtLeast
.Height = CentimetersToPoints(0.9)
End With
With .Range
With .Cells
.DistributeWidth
.VerticalAlignment = wdCellAlignVerticalCenter
End With
.Font.Size = 12
With .ParagraphFormat
.Alignment = wdAlignParagraphCenter
.CharacterUnitFirstLineIndent = 0
.FirstLineIndent = CentimetersToPoints(0)
.Space1
End With
End With
.Shading.BackgroundPatternColor = wdColorAutomatic
.AutoFitBehavior (wdAutoFitContent)
.AutoFitBehavior (wdAutoFitContent)
.Select
.AutoFitBehavior (wdAutoFitWindow)
.AutoFitBehavior (wdAutoFitWindow)
With .Rows(1).Range.Font
.Name = "黑体"
.Name = "Times New Roman"
.Bold = True
End With
End With
If n = 1 Then Exit For
Next
End Sub
|
|