word里自动调整图片大小并且添加黑色框线

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

文剑至秦

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值