
word宏命令,Alt+F8创建宏
比例缩放
Dim iSha As InlineShape
Dim picwidth
Dim picheight
For Each iSha In ActiveDocument.InlineShapes
If iSha.Type = wdInlineShapePicture Then
iSha.LockAspectRatio = msoFalse '不锁定纵横比
picheight = iSha.Height
picwidth = iSha.Width
iSha.Height = picheight * 0.5 '设置高度为1.1倍
iSha.Width = picwidth * 0.5 '设置宽度为1.1倍
End If
Next
若还想使所有图片居中对齐,可在循环中加入下面的语句:
居中对齐:iSha.Range.ParagraphFormat.Alignment= wdAlignParagraphCenter
‘左对齐:wdAlignParagraphLeft
‘右对齐’:wdAlignParagraphright
文档中所有图片固定长高
Dim iSha As InlineShape
For Each iSha In ActiveDocument.InlineShapes
If iSha.Type = wdInlineShapePicture Then
iSha.LockAspectRatio = msoFalse '不锁定纵横比
iSha.Width = CentimetersToPoints(5) '宽5CM
iSha.Height = CentimetersToPoints(5) '高5CM
End If
Next