编写目的
由于工作需要,渗透测试报告中的图片需要进行特殊处理,在繁忙的工作中,处理诸多的图片成为了一项不得不解决而又费时的工作。
编写需求
将文档中所有的图片进行如下处理:去除缩进,居中,加0.75磅边框
解决方案
利用VBA编码进行图像处理
打开word文档



代码如下:
Sub image_processing()
Dim oInlineShape As InlineShape
Application.ScreenUpdating = False
For Each oInlineShape InActiveDocument.InlineShapes
With oInlineShape.Borders
.OutsideLineStyle = wdLineStyleSingle
.OutsideColorIndex = wdColorAutomatic
.OutsideLineWidth = wdLineWidth075pt
End With
IfLen(oInlineShape.Range.Paragraphs(1).Range.Text) = 2 Then
oInlineShape.Range.Paragraphs.Reset
oInlineShape.Range.Paragraphs.Alignment= wdAlignParagraphCenter
End If
Next
Application.ScreenUpdating = True
End Sub



来源:freebuf.com 2019-01-30 21:49:55 by: 凯信特安全团队
