At least in theory, you should be able to delete InlineShapes with a very similar macro:
Sub Macro1()
Dim oShape As InlineShape
Dim i As Integer
For i = ActiveDocument.InlineShapes.Count To 1 Step -1
Set oShape = ActiveDocument.InlineShapes(i)
If oShape.Type = msoPicture Then
oShape.Delete
Else
Debug.Print oShape.Type
End If
Next i
Set oShape = Nothing
End Sub
EDIT: The above code only acts on shape objects that are pictures. That is what the msoPicture is referring to. I initially overlooked this when I tried to customize the original macro.
However, I am not sure that I remember correctly which objects are recognized as inline shapes, anymore. :-(
Are you able to share a sample document with the forum? I am not referring to the entire 3000 page document, obviously, but a much shorter version with just the shapes/graphics and some dummy text.
__________________
Stefan Blom
Microsoft Word MVP
Microsoft 365 apps for business
Windows 11 Professional
Last edited by Stefan Blom; 03-01-2024 at 07:27 AM.
|