VBA_批量调整图片宽度
2017-04-09 15:54
351 查看
'版心尺寸大小(假设 Word 2003 中,A4纵向纸张,宽度已知是21厘米,左边距2.5厘米,右边距2.5厘米,所以,版心尺寸=宽度-左边距-右边距=16厘米) Dim Width As Single, Left As Single, Right As Single Width = Round(ActiveDocument.PageSetup.PageWidth / 28.35) Left = Round(ActiveDocument.PageSetup.LeftMargin / 28.35, 1) Right = Round(ActiveDocument.PageSetup.RightMargin / 28.35, 1) MsgBox "版心尺寸是 " & (Width - Left - Right) & " 厘米" Sub 图片宽度批量调整() Dim i Dim j Dim oldHeight Dim oldWidth Dim newHeight Dim newWidth Dim docWidth docWidth = 15 * 28.345 On Error Resume Next For i = 1 To ActiveDocument.InlineShapes.Count oldWidth = ActiveDocument.InlineShapes(i).Width oldHeight = ActiveDocument.InlineShapes(i).Height '如果长度大于内容区的长度则自动修改图片长度为内容区,图片高度按照比例压缩 If oldWidth > docWidth Then newWidth = docWidth newHeight = newWidth * oldHeight / oldWidth End If ActiveDocument.InlineShapes(i).Height = newHeight '修改为自己需要的值 ActiveDocument.InlineShapes(i).Width = newWidth '修改为自己需要的值 Next For j = 1 To ActiveDocument.Shapes.Count oldWidth = ActiveDocument.InlineShapes(i).Width oldHeight = ActiveDocument.InlineShapes(i).Height '如果长度大于内容区的长度则自动修改图片长度为内容区,图片高度按照比例压缩 If oldWidth > docWidth Then newWidth = docWidth newHeight = newWidth * oldHeight / oldWidth End If ActiveDocument.InlineShapes(j).Height = newHeight '修改为自己需要的值 ActiveDocument.InlineShapes(j).Width = newWidth '修改为自己需要的值 Next End Sub
相关文章推荐
- Excel VBA 调整图片高度宽度等于所在单元格高度宽度
- 怎样批量调整word 图片大小?
- 批量将导入的图片生成对应的元件调整为无损位图质量,设置链接项导出,发布并生成配置文件,fljs小命令脚本 - [jsfl]
- div里面的图片超出div的宽度,自动调整大小。
- 百度的富文本编辑器UEditor批量添加图片自动加上宽度和高度的属性
- 【Android】根据宽度自动调整(参照图片本身尺寸)高度
- js 客户端动态调整图片宽度 解决方案
- Excel单元格内插入图片(VBA创建函数,根据图片名称批量插入)
- 批量调整word 图片大小
- div里面的图片超出div的宽度,自动调整大小。
- python3.6深度学习图片集处理项目源代码(为cnn等准备图片集合,批量生成、删除、改名、旋转、调整大小)
- 网页载入过程中自动调整图片的宽度
- 批量图片大小调整
- 在world中批量调整图片的大小
- wps 批量调整图片大小 宏
- 【转】Photoshop批量调整图片大小的方法
- 批量修改Word 2010图片宽度
- Excel VBA 根据合并单元格大小调整图片大小
- VBA批量调整图片宽度
- python3.6深度学习图片集处理项目源代码(为cnn等准备图片集合,批量生成、删除、改名、旋转、调整图片大小,包括删除指定路径下所有文件)