有许多docx文件内都被插入了很小的图片,这些小图片毫无意义。夹杂在正常图片中,用录制宏无法解决,求vba高手写个代码批量处理
第1个回答 2022-08-28
以下程序供您参考,希望对你有所帮助。
PS: 操作前请将WORD文档另作备份,谨防误操作,因数据丢失而致遗恨万年!!!
(引用外来程序均请养成数据备份的好习惯!!!)
Sub picDelete()
Dim oDoc As Document
Set oDoc = Word.ActiveDocument
Dim oShape As Shape
Dim oInLineShape As InlineShape
mSize = 10 '设置图片高宽限值为10CM
nRate = 28.345 '默认图片分辨率Dpi=72Px, cm(厘米):Px(像素)=1:28.345,
With oDoc
For Each oShape In .Shapes '删除文字环绕型图片
If oShape.Width < mSize * nRate And oShape.Height < mSize * nRate Then
oShape.Delete
End If
Next
For Each oInLineShape In .InlineShapes '删除嵌入型图片
If oInLineShape.Width < nRate * nRate And oInLineShape.Height < mSize * nRate Then
oInLineShape.Delete
End If
Next
End With
oDoc.Save '文档保存
End Sub