1.Word中VBA代码如何处理嵌入的图片真正做到居中
按Alt+F11组合键打开VBA窗口,双击左侧的“工程资源管理器”窗口的“ThisDocument”,在弹出的空白窗口中输入以下代码:
Sub AAA1()
Dim myS As InlineShape
Application.ScreenUpdating = False
For Each myS In ActiveDocument.InlineShapes
If Len(myS.Range.Paragraphs(1).Range.Text) = 2 Then
myS.Range.Paragraphs.Alignment = wdAlignParagraphCenter
End If
Next
Application.ScreenUpdating = True
End Sub
按F5键执行即可。
2.用VBA批量处理word 中的表格:将表格内容调整为上下,左右居中,
你把 For Each oTable In oDoc.Tables oTable.Range.Font.Name = "黑体" ' 改变表格字体为“黑体” oTable.Range.Font.Size = 10.5 ' 改变表格字号为12磅 Next改为: For Each oTable In oDoc.Tables oTable.AutoFitBehavior (wdAutoFitWindow) '根据窗口调整内容 oTable.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '水平居中 oTable.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter '垂直居中 Next。
污污污污污污