【发布时间】:2021-03-02 09:57:41
【问题描述】:
我正在使用以下宏来调整通过 word 中的图片内容控件功能添加的图像的大小,作为从图片内容控件中删除图像后发生的默认调整大小的解决方案(不保留大小并且图像框恢复为更大的尺寸)。
此宏会调整大小,但我希望了解如何在每次从图片内容控件框中添加或删除图像时自动运行宏?
Sub ResizePhotos()
Dim pic As InlineShape
For Each pic In ActiveDocument.InlineShapes
With pic
.LockAspectRatio = msoTrue
If .Width > .Height Then
.Height = InchesToPoints(0.5)
Else
.Width = InchesToPoints(0.5)
End If
.Range.Paragraphs(1).Alignment = wdAlignParagraphCenter
End With
Next
结束子
【问题讨论】:
-
添加或删除图片时不会触发事件。你能得到的最接近的可能是
ContentControlOnExit。 -
@TimothyRylatt 感谢您的反馈 - 您能否就编写代码提供任何指导来支持这一点?任何帮助将不胜感激
-
为什么不先查找the documentation?