- 帖子
- 601
- 积分
- 1128
- 技术
- 166
- 捐助
- 0
- 注册时间
- 2022-6-20
|
2楼
发表于 2022-8-4 12:11
| 只看该作者
Sub 图片锁定纵横比自适应页宽()
'
' 图片锁定纵横比自适应页宽 宏
'
'
Dim shap As InlineShape
Dim maxWith
maxWith = ActiveDocument.PageSetup.PageWidth - ActiveDocument.PageSetup.LeftMargin - ActiveDocument.PageSetup.RightMargin '宽度自适应
For Each shap In ActiveDocument.InlineShapes
Debug.Print shap.Type; "Shap.Type"; wdInlineShapePicture
If (shap.Type = wdInlineShapeLinkedPicture) Or (shap.Type = wdInlineShapePicture) Then
'If shap.Width > maxWith Then
'Shap.LockAspectRatio = msoTrue
Debug.Print "before width: "; shap.Width
Debug.Print "before Height: "; shap.Height
oW = shap.Width
oH = shap.Height
aspect = oH / oW 'aspect ratio
shap.Width = maxWith
shap.Height = aspect * maxWith
Debug.Print "after width: "; shap.Width
Debug.Print "after Height: "; shap.Height
'End If
End If
Next
End Sub |
|