用户登录
用户注册

分享至

wordvba居中

  • 作者: 污污污污污污
  • 来源: 51数据库
  • 2020-04-21

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。

转载请注明出处51数据库 » wordvba居中

软件
前端设计
程序设计
Java相关