Deleting specific shapes from document using code

L

LDMueller

In Word 2003 I have a template with three shapes named Picture 7, Picture 8
and Picture 9. When I have the template open, I type text on the document,
then I run another macro opening UserForm1 which has three Option buttons.
OptionButton1 deletes Picture 7, OptionButton2 deletes Picture 7 and Picture
9 and OptionButton3 deletes Picture 7, Picture 8 and Picture 9.

Below is the code for OptionButton2.

Private Sub OptionButton2_Click()
Selection.HomeKey Unit:=wdStory
ActiveDocument.Shapes("Picture 7").Select
Selection.ShapeRange.Delete
ActiveDocument.Shapes("Picture 9").Select
Selection.ShapeRange.Delete
UserForm1.Hide
End Sub

This code doesn't always delete the images. Can anyone suggest better code
or help me with this.

Your assistance is greatly appreciated.

Thanks in advance...

LDMueller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top