Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2023, 10:52 PM
Xavier Xavier is offline How to delete images from entire Word document Windows XP How to delete images from entire Word document Office 2016
Advanced Beginner
How to delete images from entire Word document
 
Join Date: Jul 2023
Posts: 52
Xavier is on a distinguished road
Default How to delete images from entire Word document

I have a very long (9000 page) .rtf Word document. It was created via OCR from 9000 pages of hardcopy.

Occasionally the text includes images (as per the attached image).

I realise there is the option of replacing all graphics with nothing, and that should delete all the images.



(As in find ^g replace [leave blank]).

Nonetheless when I do this it says there were zero replacements made.

This is driving me crazy, as clearly there are graphics inside the document.

Could the images I see be something other than graphics? How can I delete them all?
Attached Images
File Type: jpg Word problem with graphic info.JPG (40.0 KB, 26 views)
Reply With Quote
  #2  
Old 08-04-2023, 06:26 AM
Kim Yoona Kim Yoona is offline How to delete images from entire Word document Windows 11 How to delete images from entire Word document Office 2021
Novice
 
Join Date: Jul 2022
Posts: 11
Kim Yoona is on a distinguished road
Default

Hi, maybe this will help you... How to select multiple photos in Word and why is it blank when selecting multiple objects-Lionsure
Reply With Quote
  #3  
Old 08-04-2023, 06:27 AM
gmayor's Avatar
gmayor gmayor is offline How to delete images from entire Word document Windows 10 How to delete images from entire Word document Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Documents are made up of a variety of story ranges or 'layers'. Inline graphics are in the text layer and will be accessed with ^g. Images that have a wrap option set are in the graphics layer and thus will not. You need to change the wrap to in-line in order to remove them by this method.
An alternative is to use a macro. The following should remove floating graphics
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
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 08-07-2023, 07:31 PM
Xavier Xavier is offline How to delete images from entire Word document Windows XP How to delete images from entire Word document Office 2016
Advanced Beginner
How to delete images from entire Word document
 
Join Date: Jul 2023
Posts: 52
Xavier is on a distinguished road
Default

Thanks so much for the response. I haven't had a lot of experience with running Macros.
I thought I had done everything right, but when I run the Macro you gave me I get a message "Microsoft Visual Basic for Applications. Compile error: Expected End Sub"

What have I done wrong?
Reply With Quote
  #5  
Old 08-07-2023, 09:22 PM
Guessed's Avatar
Guessed Guessed is offline How to delete images from entire Word document Windows 10 How to delete images from entire Word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You probably missed the last line of code when you pasted it into VBA

It should end with a line that says
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #6  
Old 08-08-2023, 06:38 AM
skeezix skeezix is offline How to delete images from entire Word document Windows 10 How to delete images from entire Word document Office 97-2003
Competent Performer
 
Join Date: Jan 2019
Posts: 100
skeezix is on a distinguished road
Default

Do layered images exist in Word 2000? Where can I find more info about them?
Reply With Quote
  #7  
Old 12-04-2023, 11:31 PM
Xavier Xavier is offline How to delete images from entire Word document Windows XP How to delete images from entire Word document Office 2016
Advanced Beginner
How to delete images from entire Word document
 
Join Date: Jul 2023
Posts: 52
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, 10 views)
File Type: jpg Screenshot showing image2.jpg (193.9 KB, 10 views)
Reply With Quote
  #8  
Old 12-05-2023, 03:17 PM
Guessed's Avatar
Guessed Guessed is offline How to delete images from entire Word document Windows 10 How to delete images from entire Word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

ImageRemover has no code in it so I'm not surprised nothing happens with that macro.

The other macro is testing each floating shape to see what it's type is and only deleting them if they are an msoPicture. Apparently the shapes you want to get rid of are not msoPicture types so maybe you don't want to restrict the macro to only msoPicture.
You could ask the macro to tell you what types of shapes are in the document by changing this line
Code:
If oShape.Type = msoPicture Then oShape.Delete
to
Code:
If oShape.Type = msoPicture Then
 oShape.Delete
Else
  Debug.Print oShape.Type
End If
The result will be a series of numbers in your Immediate Window. Those numbers will show you the id of the Shape types that are NOT being deleted.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 12-05-2023, 11:26 PM
Xavier Xavier is offline How to delete images from entire Word document Windows XP How to delete images from entire Word document Office 2016
Advanced Beginner
How to delete images from entire Word document
 
Join Date: Jul 2023
Posts: 52
Xavier is on a distinguished road
Default

Thanks again for all your assistance. I couldn't seem to sort it out with that code either, but I decided to copy all the text and paste it into a new document as text.

That seems to have done the job for now. It may screw with the formatting a bit, though so far any changes have been easy to manually fix.
Reply With Quote
Reply

Tags
deleting, graphics, photos



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Word macro to delete text throughout the entire document JTell Word VBA 8 07-06-2022 12:19 PM
How to delete images from entire Word document Delete entire paragraph after key word jeffreybrown Word 2 07-27-2018 02:29 PM
Single step Word Styles from Source Document through entire Destination document? xbliss Word 6 08-27-2016 09:36 PM
MS Word auto formats entire document with EVERY change rooter Word 2 02-22-2015 10:05 AM
New here: How do i delete an entire notebook? DixieSister OneNote 2 02-20-2015 12:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft