word里自动调整图片大小并且添加黑色框线
2016-09-01 15:06
696 查看
1.应用
word书写过程有时候需要批量修改图片大小使得格式统一化,对每个图片进行修改费时费力,写了一些小程序批量修改希望对需要经常写word的人有帮助。
2.程序
2.1图片大小调整
' Sub 图片格式调整()
'
' 图片格式调整 宏
Dim n '图片个数
On Error Resume Next '忽略错误
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes类型图片
ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '不锁定纵横比,重要,不然会变形
ActiveDocument.InlineShapes(n).Height = 6.73 * 28.35 '设置图片高度为 260px,1cm=28.35
ActiveDocument.InlineShapes(n).Width = 14.57 * 28.35 '设置图片宽度 413px
ActiveDocument.InlineShapes(n).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '图片居中
Next n
' For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片
'
' ActiveDocument.Shapes(n).Height = 400 '设置图片高度为 400px
'
' ActiveDocument.Shapes(n).Width = 413 '设置图片宽度 300px
'
' ActiveDocument.InlineShapes(n).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '图片居中
'
' Next n
End Sub给图片增加框
2.2图片添加黑色边框
Sub 增加图片边框()
'' 增加图片边框 宏
Dim oInlineShape As InlineShape
Application.ScreenUpdating = False
For Each oInlineShape In ActiveDocument.InlineShapes
With oInlineShape.Borders
.OutsideLineStyle = wdLineStyleSingle
.OutsideColorIndex = wdColorAutomatic
.OutsideLineWidth = wdLineWidth050pt
End With
Next
Application.ScreenUpdating = True
End Sub
word书写过程有时候需要批量修改图片大小使得格式统一化,对每个图片进行修改费时费力,写了一些小程序批量修改希望对需要经常写word的人有帮助。
2.程序
2.1图片大小调整
' Sub 图片格式调整()
'
' 图片格式调整 宏
Dim n '图片个数
On Error Resume Next '忽略错误
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes类型图片
ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '不锁定纵横比,重要,不然会变形
ActiveDocument.InlineShapes(n).Height = 6.73 * 28.35 '设置图片高度为 260px,1cm=28.35
ActiveDocument.InlineShapes(n).Width = 14.57 * 28.35 '设置图片宽度 413px
ActiveDocument.InlineShapes(n).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '图片居中
Next n
' For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片
'
' ActiveDocument.Shapes(n).Height = 400 '设置图片高度为 400px
'
' ActiveDocument.Shapes(n).Width = 413 '设置图片宽度 300px
'
' ActiveDocument.InlineShapes(n).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '图片居中
'
' Next n
End Sub给图片增加框
2.2图片添加黑色边框
Sub 增加图片边框()
'' 增加图片边框 宏
Dim oInlineShape As InlineShape
Application.ScreenUpdating = False
For Each oInlineShape In ActiveDocument.InlineShapes
With oInlineShape.Borders
.OutsideLineStyle = wdLineStyleSingle
.OutsideColorIndex = wdColorAutomatic
.OutsideLineWidth = wdLineWidth050pt
End With
Next
Application.ScreenUpdating = True
End Sub
相关文章推荐
- Joda-Time 简介
- pycharm——激活码
- leetcode:sort:Maximum Gap(164)
- Ubuntu16.04安装nginx
- 面向 Linux 新用户的八款最佳 Linux 发行版
- java程序实现删除本地文件
- vim常用命令
- Go的50度灰:Golang新开发者要注意的陷阱和常见错误
- easyUI吧复选框选中的value值返回
- 如何把UIView转成UIImage,解决模糊失真问题
- 有章法的学习c++(0)使用命令行编译文件
- Vuejs——(4)v-if、v-for
- Codeforces Beta Round #27-E. Number With The Given Amount Of Divisors
- Mysql 主键是UUID查询上一条和下一条的实现
- WCF wsHttpBinding in SoapUI
- ajax跨域请求
- Nginx源代码分析之accept(十六)
- 代码笔记 | ajax实现服务器与浏览器长连接的功能
- 大概总结了一下jQuery的一些基础知识点
- 2