创建新的宏名为所有表格按照窗口自动调整宽度,代码如下:
Sub 所有表格按照窗口自动调整宽度()
Application.Browser.Target = wdBrowseTable
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 '垂直居中
Next i
End Sub