![]() |
|
#1
|
|||
|
|||
|
Hi all,
I'm trying to automate the process of deleting old (dated) icons and images from a word document. The same images are repeated throughout the document. I've written this macro to delete images 'identical' to the selected. As the images do not seem to have names, I've been finding images of the same dimensions (imperfect I know). Is there a better way to do this or a way to find a unique identifier for identical shapes (even if resized)? A number of the icons have been slightly resized so I have to run this macro multiple times. Heres what I've got: Code:
Sub DeleteSelectedPicture()
Dim Shp As Shape, iShp As InlineShape
Dim DC As Integer, SHeight As Variant, SWidth As Variant
DC = 0
If Selection.InlineShapes.Count = 1 Then
SHeight = Selection.InlineShapes(1).Height
SWidth = Selection.InlineShapes(1).Width
End If
If Selection.ShapeRange.Count = 1 Then
SHeight = Selection.ShapeRange(1).Height
SWidth = Selection.ShapeRange(1).Width
End If
With ActiveDocument
For Each iShp In .InlineShapes
If iShp.Height = SHeight And iShp.Width = SWidth Then
iShp.Delete
DC = DC + 1
End If
Next
For Each Shp In .Shapes
If Shp.Height = SHeight And Shp.Width = SWidth Then
Shp.Delete
DC = DC + 1
End If
Next
MsgBox DC & " pictures deleted."
End With
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Identical computers | MeCasa | Office | 0 | 09-23-2019 03:43 PM |
| how to delete multiple images at the same time in all slides. | yeshwanthkota111 | PowerPoint | 2 | 09-10-2015 04:04 AM |
| how to show identical data once only? | heidiau | Mail Merge | 1 | 09-29-2013 07:44 PM |
| flag identical words? | 21rouge | Word | 1 | 09-21-2013 08:42 AM |
Delete all shapes but not the images - Possible?
|
AlmostFriday | Word VBA | 10 | 12-14-2011 12:04 AM |