mat said:
Not sure this is really a vba question but it does not seem to be a
supported feature of word's regular user interface. I would like to
have additional images available to the reader which open as popup
images when a link is clicked...kind of like you see on the web all
the time. I guess one could create a form with vba and have it open
over the document? And the image would either be embedded in the
form, which would mean a lot of forms, or else loaded somehow
dynamically...seems like a pretty basic feature but I don't find much
via google on this topic.
Thanks
There is a way, although it isn't particularly simple.
Create a userform (the "create a form with vba" you described -- see
http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm). Put an image
control and a command button on the form. I changed the default name of the
userform to frmPicture, and named the image control imgPicture, although you
can use whatever names you like. In the code for the userform, all you need
is the command button's click event, with the single line
Me.Hide
Then create a macro to display the userform. The macro will be called by
clicking a MacroButton field
(
http://word.mvps.org/faqs/tblsfldsfms/usingmacrobuttoncontent.htm), using
the technique in that article's section "Passing arguments to macrobutton
fields". The macro code would look like this:
Sub ShowPic()
Dim ufrm As frmPicture
Dim sFileName As String
If Selection.Fields.Count < 2 Then Exit Sub
sFileName = Mid$(Selection.Fields(2).Code, 10)
Set ufrm = New frmPicture
With ufrm
.imgPicture.Picture = LoadPicture(sFileName)
.Show
End With
Set ufrm = Nothing
End Sub
For each picture, insert a MacroButton field that looks like
{ { Private C:\test\some picture.jpg }Macrobutton ShowPic [Double-click to
run macro]}
You can create the inner Private field by typing the text inside it first,
selecting it, and pressing Ctrl+F9. A Private field is automatically
formatted as Hidden, so you need to turn on nonprinting characters in order
to see it after it's created.
Whenever a user double-clicks one of these MacroButton fields, the ShowPic
macro will run, read the picture path from the Private field, load the
picture into the userform's image control, and display the userform.
You might also be interested in the section "Double-click or single-click"
in
http://word.mvps.org/faqs/tblsfldsfms/HLinksInForms.htm.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.