我写了这个宏,将文档中的所有形状都转换为图像:
Sub AllShapeToPic()
For Each oShp In ActiveDocument.Shapes
oShp.Select
Selection.Cut
Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
Next oShp
End Sub
但是当我运行它时,没有任何形状转换为图像。
我的宏代码有什么问题?
欢迎来到操作您正在浏览的收藏集的美好世界。切割的那一刻,您正在有效地从集合中删除形状,从而改变了循环。
如果要遍历形状(或表行或其他内容)并从该集合中删除某些内容,只需向后走:
Dim i As Integer, oShp As Shape
For i = ActiveDocument.Shapes.Count To 1 Step -1
Set oShp = ActiveDocument.Shapes(i)
oShp.Select
Selection.Cut
Selection.PasteSpecial Link:=False, dataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
Next i
替代表(警告:未经测试!)
Dim tbl As Table
For i = ActiveDocument.Tables.Count To 1 Step -1
Set tbl = ActiveDocument.Tables(i)
tbl.Select
Selection.Cut
Selection.PasteSpecial Link:=False, dataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
Next i
对于方程式:方程式是InlineShapes并具有“ OMath”属性。使用它来识别方程式对象。警告:未经测试
Dim equation As InlineShape
For i = ActiveDocument.InlineShapes.Count To 1 Step -1
Set equation = ActiveDocument.InlineShapes(i)
If equation.OMath > 0 Then
equation.Select
Selection.Cut
Selection.PasteSpecial Link:=False, dataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
End If
Next i
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句