使用下面代码设置统一大小
-
打开 Microsoft Word,按下 “Alt + F11” 键进入 VBA 编辑器。
-
在 “Project” 窗口中,右键单击 “Microsoft Word Object”,选择 “Insert” > “Module” 来创建一个新模块。
-
在新模块中,输入以下代码来实现简单的图片大小统一任务:
Sub Example()
Dim oInlineShape As InlineShape
Application.ScreenUpdating = False
For Each oInlineShape In ActiveDocument.InlineShapes
With oInlineShape.Borders
.OutsideLineStyle = wdLineStyleSingle
.OutsideColorIndex = wdColorAutomatic
.OutsideLineWidth = wdLineWidth050pt
End With
Next
Application.ScreenUpdating = True
End Sub
Sub FormatPics()
Dim TuPian As InlineShape
For Each TuPian In ActiveDocument.InlineShapes
If TuPian.Type = wdInlineShapePicture Then
TuPian.LockAspectRatio = msoFalse '不锁定图片的宽高比
TuPian.Width = CentimetersToPoints(7.2) '设置图片宽度为10CM
TuPian.Height = CentimetersToPoints(7.5) '设置图片高度为8CM
End If
Next
End Sub
- 按下 “F5” 键来运行宏。