Word图片批量居中+批量边框

打开word,输入alt+f11

请添加图片描述
请添加图片描述
下个文档想要使用的时候,只需alt+f11找到normal的模块1运行
在这里插入图片描述

如果只需要所有图片居中,将代码withendwith删除即可;同理,只需要边框将居中对齐那行代码删去即可只加边框

以下是AddBordersAndCenterImages的代码:

Sub AddBordersAndCenterImages()
    Dim i As Long
    Dim shape As InlineShape
    
    ' 遍历文档中的所有内嵌形状
    For Each shape In ActiveDocument.InlineShapes
        ' 检查形状是否为图片
        If shape.Type = wdInlineShapePicture Or shape.Type = wdInlineShapeLinkedPicture Then
            ' 给图片添加边框
            With shape
                .Borders.Enable = True
                .Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
                .Borders(wdBorderLeft).Color = wdColorAutomatic
                .Borders(wdBorderRight).LineStyle = wdLineStyleSingle
                .Borders(wdBorderRight).Color = wdColorAutomatic
                .Borders(wdBorderTop).LineStyle = wdLineStyleSingle
                .Borders(wdBorderTop).Color = wdColorAutomatic
                .Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
                .Borders(wdBorderBottom).Color = wdColorAutomatic
            End With
            ' 将图片居中对齐
            shape.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
        End If
    Next shape
End Sub

默认加0.75磅黑框

Enjoy~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值