在WORD中批量修改图片大小

您所在的位置:网站首页 word如何批量修改图片大小尺寸格式 在WORD中批量修改图片大小

在WORD中批量修改图片大小

2024-07-16 21:16| 来源: 网络整理| 查看: 265

今天在word中批量修改图片时发现了word一个强大的功能,不多说废话,直接附上步骤:

1.首先按一定的顺序将图片插入word当中; 2.点击“视图”----“宏”,再选择“查看宏”; 3.在宏名中输入自己定义的名字,这里名字定义为“daxiao” 4.输入以下代码:

Sub daxiao()'这个宏的名字是daxiao Dim n '图片个数 On Error Resume Next '忽略错误 For n=1 To ActiveDocument.InlineShapes.Count ActiveDocument.InlineShapes(n).Height=5*28.5 '设置图片高为5cm ActiveDocument.InlineShapes(n).Width=4*28.5 '图片宽为4cm Next n End Sub

PS:若想设置统一宽度或统一高度则可用以下代码来实现:

Sub 设为统一宽度() Dim n '图片个数 Dim picwidth Dim picheight Dim newWidth newWidth = 300 '设置图片的统一宽度 On Error Resume Next '忽略错误 For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes 类型图片 picheight = ActiveDocument.InlineShapes(n).Height picwidth = ActiveDocument.InlineShapes(n).Width ActiveDocument.InlineShapes(n).Height = picheight * newWidth / picwidth ActiveDocument.InlineShapes(n).Width = newWidth Next n For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片 picheight = ActiveDocument.Shapes(n).Height picwidth = ActiveDocument.Shapes(n).Width Debug.Print picheight ActiveDocument.InlineShapes(n).Height = picheight * newWidth / picwidth ActiveDocument.InlineShapes(n).Width = newWidth Next n End Sub Sub 设为统一高度() Dim n '图片个数 Dim picwidth Dim picheight Dim newHeight newHeight = 200 '设置统一高度时修改此数值 On Error Resume Next '忽略错误 For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes 类型图片 picheight = ActiveDocument.InlineShapes(n).Height picwidth = ActiveDocument.InlineShapes(n).Width ActiveDocument.InlineShapes(n).Height = newHeight ActiveDocument.InlineShapes(n).Width = picwidth * newHeight / picheight Next n For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片 picheight = ActiveDocument.Shapes(n).Height picwidth = ActiveDocument.Shapes(n).Width Debug.Print picheight ActiveDocument.InlineShapes(n).Height = newHeight ActiveDocument.InlineShapes(n).Width = picwidth * newHeight / picheight Next n End Sub

以上就是word中批量修改图片大小的方法,在后来的使用中,还查到可以将图片保存为较老版本的word,即doc格式,可以直接批量修改图片大小和格式,但不建议这样做,因为这样容易使得图片格式混乱,不易后面的使用和排版。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3