In Word 2003 I have a template with three shapes named Picture 7,

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
 
C

Cindy M.

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.
If these are the names Word gave to the images, then it's possible Word has
changed the names at some point. You can assign your own names to these images,
using VBA (ActiveDocument.Shapes(indexNumber).Name = "My Name"). Word will not
change any names you assign.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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