B
brett
I thought this would be easy, but it's giving me fits. I want my macro to
run on a single slide while in the edit mode of PPT 2002, and delete certain
slide items that have specific names. But it always misses one. One. Always.
For example on a title/text slide layout, I have 4 objects in the slide. The
first two (placeholders) have default names and the second two (rectangles)
have been assigned custom names via VBA:
Shapes:
Placeholder(1) with name "rectangle 2"
Placeholder(2) with name "rectangle 4"
Rectangle with name: "tempOrangeBox"
Rectangle with name: "tempBlueBox"
So, I use the following code to delete any objects with a name beginning
with "temp", and it consistantly misses one "temp" object, no matter how
many there are. If I have two, it finds only one, if I have three it finds
only two. The shape it misses has the "temp" name and it can be verified in
the multiple object tool as well through VBA.
BTW, I have the same problem when I run it on shapes with default names. For
example, with three ovals in a slide, I change the code to delete anything
starting with "oval" and it deletes only two of the three ovals. So, I'm not
sure my issue has to do with custom names. Here's what I use:
Sub DelTempShapes()
Dim oShape As Shape
For Each oShape In ActiveWindow.Selection.SlideRange.Shapes
With oShape
If Left(.Name, 4) = "temp" Then .Delete
End With
Next oShape
End Sub
I'm sure I'm just missing something. Probebly something dumb. But, I would
sure love someone to point it out or show me a better way to do this.
Thank you for your time,
Brett
run on a single slide while in the edit mode of PPT 2002, and delete certain
slide items that have specific names. But it always misses one. One. Always.
For example on a title/text slide layout, I have 4 objects in the slide. The
first two (placeholders) have default names and the second two (rectangles)
have been assigned custom names via VBA:
Shapes:
Placeholder(1) with name "rectangle 2"
Placeholder(2) with name "rectangle 4"
Rectangle with name: "tempOrangeBox"
Rectangle with name: "tempBlueBox"
So, I use the following code to delete any objects with a name beginning
with "temp", and it consistantly misses one "temp" object, no matter how
many there are. If I have two, it finds only one, if I have three it finds
only two. The shape it misses has the "temp" name and it can be verified in
the multiple object tool as well through VBA.
BTW, I have the same problem when I run it on shapes with default names. For
example, with three ovals in a slide, I change the code to delete anything
starting with "oval" and it deletes only two of the three ovals. So, I'm not
sure my issue has to do with custom names. Here's what I use:
Sub DelTempShapes()
Dim oShape As Shape
For Each oShape In ActiveWindow.Selection.SlideRange.Shapes
With oShape
If Left(.Name, 4) = "temp" Then .Delete
End With
Next oShape
End Sub
I'm sure I'm just missing something. Probebly something dumb. But, I would
sure love someone to point it out or show me a better way to do this.
Thank you for your time,
Brett