Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-20-2019, 05:02 PM
ads747 ads747 is offline Delete identical images Mac OS X Delete identical images Office 2016 for Mac
Novice
Delete identical images
 
Join Date: Nov 2019
Posts: 1
ads747 is on a distinguished road
Default Delete identical images

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

Reply With Quote
 



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 identical images Delete all shapes but not the images - Possible? AlmostFriday Word VBA 10 12-14-2011 12:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:26 AM.


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