VBA_批量调整图片宽度
来源:互联网 发布:extend软件 编辑:程序博客网 时间:2024/04/28 06:25
'版心尺寸大小(假设 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 iDim jDim oldHeightDim oldWidthDim newHeightDim newWidthDim docWidthdocWidth = 15 * 28.345On Error Resume NextFor 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 '修改为自己需要的值NextFor 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 '修改为自己需要的值NextEnd Sub
0 0
- VBA_批量调整图片宽度
- VBA批量调整图片宽度
- 自动调整宽度的图片按钮
- Excel VBA 调整图片高度宽度等于单元格高度宽度
- 批量修改Word 2010图片宽度
- 批量调整word中图片的大小
- 网页载入过程中自动调整图片的宽度
- jquery自动调整内容页中图片的宽度
- 【Android】根据宽度自动调整(参照图片本身尺寸)高度
- Excel VBA 调整图片高度宽度等于所在单元格高度宽度
- 使用宏对word中的图片批量调整大小
- 文本框宽度调整
- JS 调整表格宽度
- DropDownList宽度调整
- jqgrid调整宽度自适应
- 调整文本框的宽度
- 调整VNC屏幕宽度
- 表格宽度调整小记
- [NLP论文阅读]Distributed Representations of Sentences and Documents
- 排序(二)----希尔排序
- View.onMeasure()
- Intelx86使用的寄存器
- gulp举例
- VBA_批量调整图片宽度
- 给linux添加一个系统调用(linux-4.10.1)
- iOS 定位功能的实现详解
- OC的内存管理
- leetcodeOJ 62. Unique Paths
- 答题卡识别软件
- BZOJ P1497[NOI2006]最大获利
- VS2013 无法使用'inet_ntoa'
- Android SEAndroid