1.应用
word书写过程有时候需要批量修改图片大小使得格式统一化,对每个图片进行修改费时费力,写了一些小程序批量修改希望对需要经常写word的人有帮助。
2.程序
2.1图片大小调整
' Sub 图片格式调整()
'
' 图片格式调整 宏
Dim n '图片个数
On Error Resume Next '忽略错误
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes类型图片
ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '不锁定纵横比,重要,不然会变形
ActiveDocument.InlineShapes(n).Height = 6.73 * 28.35 '设置图片高度为 260px,1cm=28.35
ActiveDocument.InlineShapes(n).Width = 14.57 * 28.35 '设置图片宽度 413px
ActiveDocument.InlineShapes(n).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '图片居中
Next n
' For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片
'
' ActiveDocument.Shapes(n).Height = 400 '设置图片高度为 400px
'
' ActiveDocument.Shapes(n).Width = 413 '设置图片宽度 300px
'
' ActiveDocument.InlineShapes(n).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '图片居中
'
' Next n
End Sub给图片增加框
2.2图片添加黑色边框
Sub 增加图片边框()
'' 增加图片边框 宏
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