Word宏命令实现自动调整图片大小

/ 0评 / 2

自动切图片代码

Sub 批量图片大小()

Dim iSha As InlineShape

For Each iSha In ActiveDocument.InlineShapes

If iSha.Type = wdInlineShapePicture Then

'iSha.LockAspectRatio = msoFalse '不锁定纵横比

iSha.LockAspectRatio = msoTrue '锁定纵横比

iSha.Width = CentimetersToPoints(5) '宽CM

'iSha.Height = CentimetersToPoints(6) '高CM

End If

Next

End Sub

自动添加边框

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