找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 17425|回复: 1

[文本处理] 让word文档中的图片适配页面大小

[复制链接]
发表于 2022-8-4 11:17:15 | 显示全部楼层 |阅读模式
现在的word文档有200页,每一页都插入了一张照片,怎样批处理设置可以把所有照片适配文档的页面尺寸,完整显示整张图片?
发表于 2022-8-4 12:11:56 | 显示全部楼层
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-19 18:12 , Processed in 0.016031 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表