Eric Shen
asked on
Deleting specific photos based on height and width in VBA powerpoint
Hi.
I am working with a 800 powerpoint slide document and was wondering if there was a way to delete images based off of their height and width dimensions. The best I could find was someone's code deleting all images. I was wondering if it is possible to tweak it as I am not that versed in VBA powerpoint. Thanks:
Sub delete()
Dim osld As Slide
Dim I As Integer
For Each osld In ActivePresentation.Slides
For I = osld.Shapes.Count To 1 Step -1
If osld.Shapes(I).Type = msoPicture Then osld.Shapes(I).delete
Next I
Next osld
End Sub
I am working with a 800 powerpoint slide document and was wondering if there was a way to delete images based off of their height and width dimensions. The best I could find was someone's code deleting all images. I was wondering if it is possible to tweak it as I am not that versed in VBA powerpoint. Thanks:
Sub delete()
Dim osld As Slide
Dim I As Integer
For Each osld In ActivePresentation.Slides
For I = osld.Shapes.Count To 1 Step -1
If osld.Shapes(I).Type = msoPicture Then osld.Shapes(I).delete
Next I
Next osld
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah ha. I forgot to mention the conversion from points to inches (or cm for metric folk) but see you know about the magic number 72. Glad it worked for you. If you're happy with the solution, feel free to close off the question. Thanks :-)
ASKER
----Edit: Bush league move and forgot a period. It works! Thanks so much Jamie! -------
Sub delete()
Dim osld As Slide
Dim I As Integer
For Each osld In ActivePresentation.Slides
For I = osld.Shapes.Count To 1 Step -1
With osld
If .Shapes(I).Type = msoPicture Then
If .Shapes(I).Width = 1.69 * 72 And .Shapes(I).Height = 2.86 * 72 Then .Shapes(I).delete
End If
End With
Next I
Next osld
End Sub