使用word中的VBA 批量设置Word中所有图片大小

在VBA编辑器中,你可以创建、编辑和运行VBA宏代码,以实现自动化任务和自定义Word 功能。如果你是VBA编程初学者,可以在VBA编辑器中查看Word VBA宏代码示例,以便更好地了解如何使用VBA编写代码。

要打开VBA编辑器,你可以按照以下步骤:

  1. 文件-选项-自定义功能区-开发工具打上对钩-确定。
  1. 开发工具-visual basic

  2. 插入-模块

  1. 在其中粘贴以下内容:
python 复制代码
Sub FormatPics()

Dim Shap As InlineShape

For Each Shap In ActiveDocument.InlineShapes

If Shap.Type = wdInlineShapePicture Then

Shap.LockAspectRatio = msoTrue '锁定纵横比

Shap.Width = CentimetersToPoints(16) '宽16CM

End If

Next

End Sub

也可以不锁定纵横比:

python 复制代码
Sub FormatPics

Dim Shap As InlineShape

For Each Shap In ActiveDocument.InlineShapes

If Shap.Type = wdInlineShapePicture Then

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

Shap.Width = CentimetersToPoints(10) '宽10CM

Shap.Height = CentimetersToPoints(7) '高7CM

End If

Next

End Sub
  1. 然后点击运行即可
相关推荐
Tmin.1 天前
Word论文中遇到的
word
智航GIS1 天前
9.4 Word 自动化
python·自动化·word
深念Y2 天前
学习通下载老师没有开放下载的文档的方法
学习·pdf·word·文档·下载·学习通·开发者模式
开开心心_Every2 天前
提取PPT/Word/Excel图片工具
数据库·微信·pdf·word·powerpoint·excel·语音识别
蜡笔小鑫jolly3 天前
在WORD中插入表格后放图片一直不吻合怎么办?
word
YuQiao03033 天前
华科学位论文——驯服word公式编辑器(不是mathtype的)
编辑器·word
YuQiao03033 天前
华科学位论文——驯服word之 目录
word
重生之光头强下海当程序猿3 天前
word将所选内容超链接为文章其他内容
word
SEO-狼术3 天前
Convert Word Documents to PDF
pdf·word
发际线的忧伤4 天前
Word 的一个显示模式,页眉页脚数据丢失?
word