View Single Post
 
Old 12-04-2023, 11:31 PM
Xavier Xavier is offline Windows XP Office 2016
Advanced Beginner
 
Join Date: Jul 2023
Posts: 67
Xavier is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
You probably missed the last line of code when you pasted it into VBA

It should end with a line that says
End Sub
I did end the "End Sub" part. I have removed that error, but the code still isn't working. This is why I am doing.

Going to the View tab in Word. Clicking on Macros -> View Macros -> Create

Then I get a screen that says:

Sub Macro1()
'
' Macro1 Macro
'
'

End Sub


I am deleting all of that and pasting in:

Sub Macro1()
Dim oShape As Shape
Dim i As Integer
For i = ActiveDocument.Shapes.Count To 1 Step -1
Set oShape = ActiveDocument.Shapes(i)
If oShape.Type = msoPicture Then oShape.Delete
Next i
Set oShape = nothing
End Sub


I change the name to ImageRemover and get the below code:
Sub Macro1()
Dim oShape As Shape
Dim i As Integer
For i = ActiveDocument.Shapes.Count To 1 Step -1
Set oShape = ActiveDocument.Shapes(i)
If oShape.Type = msoPicture Then oShape.Delete
Next i
Set oShape = Nothing
End Sub
Sub ImageRemover()

End Sub


I then hit F5 -> Run

Lo and behold, the images still remain in the document.

I have already removed a fair number of images, by using ^g and replacing it with nothing. There are still heaps of other images though in my 9000 page document that remain.
Attached Images
File Type: jpg Screenshot showing image.jpg (227.8 KB, 16 views)
File Type: jpg Screenshot showing image2.jpg (193.9 KB, 16 views)
Reply With Quote