将下面的代码复制到word文档中宏->查看宏->编辑/创建的视图中,粘贴即可运行。
Dim tableNew As Table
For i = 1 To ActiveDocument.Tables.Count
'根据内容自动调整表格
ActiveDocument.Tables(i).AutoFitBehavior (wdAutoFitContent)
'根据窗口自动调整表格
ActiveDocument.Tables(i).AutoFitBehavior (wdAutoFitWindow)
'水平居中
ActiveDocument.Tables(i).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
'垂直居中
ActiveDocument.Tables(i).Range.ParagraphFormat.Alignment
= wdCellAlignVerticalCenter
On Error Resume Next
For j = 1 To ActiveDocument.Tables(i).Rows.Count
ActiveDocument.Tables(i).Cell(1 + j, 1).Range.Select
Selection.ParagraphFormat.LineSpacingRule = wdLineSpaceExactly
word行间距怎么调
Selection.ParagraphFormat.LineSpacing = 15
Next j
Next i
发布评论