#1
|
|||
|
|||
^g for all graphics, what about drawings only?
Hi,
I have a 4000 + pages word document with images and drawings. The drawing is actually a grey box that is used to form the background of certain text. I wish to get rid of the grey boxes. Normally, I would just search and replace all "^g". However, the document has photos as well. Does anyone know of a way to batch select only the drawings and exclude the photos? Thanks, Jay |
#2
|
||||
|
||||
Hi Jay,
Assuming your drawing is a Word rectangle autoshape, you could use code like: Code:
Sub Demo() Dim Shp As Shape With ActiveDocument For Each Shp In .Shapes If Shp.Type = msoAutoShape Then If Shp.AutoShapeType = msoShapeRectangle Then Shp.Delete End If Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi Paul,
Thanks for giving it a shot. I've tried the code. It does not work. Perhaps the rectangle I'm dealing with is not an autoshape. I'm not sure how to tell. Here's a sample of it: Thanks & warm regards, Jay |
#4
|
||||
|
||||
Hi Jay,
The grey shape in your document isn't a single object - it's a large group of other shapes that have had grey shading applied to them. If that's what you've used in all cases, and you have no other grouped shapes, you could use: Code:
Sub Demo() Dim Shp As Shape With ActiveDocument For Each Shp In .Shapes If Shp.Type = msoGroup Then Shp.Delete Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Hi Paul,
Ah, so it's a collection of grey rectangles. What a strange way to highlight text. The macro code worked. Some of the grouped shapes are actually groups of groups and on. Is there a command to instruct Word to run the code until there are no shapes left? One day I got to pick up a book on macros and start reading up. Thanks! Cheers, Jay |
#6
|
||||
|
||||
Hi Jay,
Do you mean something like: Code:
Sub Demo() Dim Shp As Shape With ActiveDocument For Each Shp In .Shapes If Shp.Type <> msoPicture Then Shp.Delete Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Not quite. When I ran the code, I found out that some of the rectangles are acutally groups of groups of ... smaller grey blocks (see attached).
In order to get rid of them all, I could run the code say, 10 times. However, I wondering if there is a command to instruct the code to loop multiple times. Thanks. |
#8
|
||||
|
||||
Hi Jay,
Try it this way: Code:
Sub Demo() Dim i As Long With ActiveDocument For i = .Shapes.Count To 1 Step -1 If .Shapes(i).Type <> msoPicture Then .Shapes(i).Delete Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Worked awesome. Thanks Paul!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
listing linked graphics | eng1ne | Drawing and Graphics | 5 | 02-28-2012 06:42 AM |
Combine is duplicating coments and graphics | Ulodesk | Word | 4 | 05-04-2011 06:10 PM |
Need To Lock Colors In Graphics | bcicio | PowerPoint | 3 | 11-24-2010 07:47 AM |
Graphics resolution | Roscoe | Drawing and Graphics | 5 | 07-02-2010 07:43 AM |
find and replace graphics | thegeester | Drawing and Graphics | 0 | 04-04-2010 04:36 AM |