批量修改word中的图片

此博客链接:

按住Alt+F8,进入宏的页面,然后起个名字,点击“”“创建”按钮。

 

输入以下代码

Sub picture()
      Dim i
      Dim Height, Weight
      Height = 150
      Weight = 80

      On Error Resume Next '忽略错误
      For i = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes类型图片
              ActiveDocument.InlineShapes(i).Height = Height '设置图片高度为 Height_px
             ActiveDocument.InlineShapes(i).Width = Weight '设置图片宽度 Weight_px
     Next i

     For i = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片
             ActiveDocument.Shapes(i).Height = Height '设置图片高度为 Height_px
             ActiveDocument.Shapes(i).Width = Weight '设置图片宽度 Weight_px
     Next i
End Sub

 

 保存,然后按住Alt+F4后,运行程序,图片就修改好了。

 

posted @ 2020-12-21 16:23  萍2樱释  阅读(483)  评论(0编辑  收藏  举报