使用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. 然后点击运行即可
相关推荐
SiYuanFeng4 小时前
【Word 排版】文本框/文字行间距异常偏大的解决方案
word
belldeep8 小时前
python:markdown + python-docx 将 Markdown 文件格式转为 Word 文档
python·word·markdown·docx
gc_229910 小时前
学习C#调用OpenXml操作word文档的基本用法(16:学习文档脚注类)
word·openxml·脚注
Fighting_p12 小时前
【预览word文档】使用插件 docx-preview 预览线上 word 文档
开发语言·c#·word
薛定谔的猫-菜鸟程序员15 小时前
基于Node.js+Pandoc实现Markdown文件无损转换为Word文档的小工具
node.js·word·vim
森森-曦1 天前
在word中如何设置从第二页开始页码编号
word
爱学习 爱分享1 天前
word中批量替换
word
selina89211 天前
word中脚注编号如何设置不显示?
word
叫我莫言鸭1 天前
关于word生成报告的POI学习
学习·word
AscendKing2 天前
java poi word首行插入文字
java·c#·word