Hello ..
I have a template that includes an image. I would like to show this image
only if a check box in the associated user form is clicked.
Is this possible?
Since it's a template, can the image actually be saved with the document?
Thanks from an expat Bavarian in NZ.
Yes, all of that is possible.
First, save the image in the template as an AutoText entry. See
http://www.word.mvps.org/FAQs/Customization/AutoText.htm. (Be careful
to set the Look In dropdown of the Insert > AutoText > AutoText dialog
to your template before clicking the Add button.)
Next, insert a bookmark at the location in the template where you want
the image to appear when it's enabled.
In the Click procedure for your OK button, write code like this,
replacing "MyPic" and "MyBkMk" with the names of your AutoText entry
and your bookmark, respectively:
Private Sub CommandButton1_Click()
Dim MyRg As Range
Set MyRg = ActiveDocument.Bookmarks("MyBkMk").Range
If CheckBox1.Value = -1 Then ' checked
With ActiveDocument
Set MyRg = .AttachedTemplate.AutoTextEntries("MyPic") _
.Insert(Where:=MyRg, RichText:=True)
.Bookmarks.Add Name:="MyBkMk", Range:=MyRg
End With
Else
If MyRg.InlineShapes.Count > 0 Then
MyRg.InlineShapes(1).Delete
ActiveDocument.Bookmarks.Add Name:="MyBkMk", Range:=MyRg
End If
End If
Me.Hide
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.