Any simple way to create popup images with word 2003?

M

mat

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
 
D

Doug Robbins - Word MVP

If you inserted the images into the document and assigned a bookmark to each
of them, for each image, you could have a macrobutton field that ran a macro
that contained the following code:

Dim boolhidden As Boolean
If ActiveWindow.View.ShowHiddenText = True Then
boolhidden = True
Else
boolhidden = False
End If
If boolhidden = True Then
ActiveWindow.View.ShowHiddenText = False
End If
With ActiveDocument.Bookmarks("Picture1").Range.Font
If .Hidden = True Then
.Hidden = False
Else
.Hidden = True
If boolhidden = True Then
ActiveWindow.View.ShowHiddenText = True
End If
End If
End With


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
M

mat

If you inserted the images into the document and assigned a bookmark to each
of them, for each image, you could have a macrobutton field that ran a macro
that contained the following code:

Dim boolhidden As Boolean
If ActiveWindow.View.ShowHiddenText = True Then
boolhidden = True
Else
boolhidden = False
End If
If boolhidden = True Then
ActiveWindow.View.ShowHiddenText = False
End If
With ActiveDocument.Bookmarks("Picture1").Range.Font
If .Hidden = True Then
.Hidden = False
Else
.Hidden = True
If boolhidden = True Then
ActiveWindow.View.ShowHiddenText = True
End If
End If
End With
In other words, hide or show the images? It's not really as good a
solution as popup images would be. How odd if there is no easy way to do
popup images in word.
 
D

Doug Robbins - Word MVP

Word is a Word Processor with some graphics and automation facilities. It
is not an animation program.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
M

mat

Word is a Word Processor with some graphics and automation facilities. It
is not an animation program.
That's silly. An animation program? Word has massive, massive extensions
beyond what a word processor *needs* to have. It allows for kinds of
data processing, very sophisticated programming, interaction with all
manner of other applications via an extensive api. It's not at all
unreasonable to hope that it might have the ability to pop up images,
without starting to be termed an animation program. Having the ability
to do that is about 5% as far from what a basic word processor would be
in comparison with many of the features that Word already supports. Word
has popup forms, popup messages...that does not make it halfway to an
animation program.

Documents are not the dead things they used to be.
 
D

Doug Robbins - Word MVP

You asked for a simple way. I am not saying that there is not a more
complex way that may be more to your liking.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Jay Freedman

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.
 
F

Fumei2 via OfficeKB.com

"Documents are not the dead things they used to be."

Oh, but how I wish they were. I wish that Word (an excellent word-processor)
was not being used as if it is a browser, or a data source like a spreadsheet,
or a layout application.....etc. etc.

True, Word has many capabilities beyond word-processing. I sincerely wish
they were ALL removed.


"additional images available to the reader which open as popup images
when a link is clicked"

I am not sure what you mean by "additional". I am also not sure what you
mean by "link is clicked". What link?

Can Word do a - sort of - popup with an image in it? Yes. A userform with
an image control on it works fine. It can not be a "link" that shows the
userform,as a hyperlink does not execute instructions. But you could use a
macrobutton, or an ActiveX commandbutton. It depends on what exactly you
want.

The image showing in the Image control can be loaded dynamically depending on
your criteria. That an an OK button to close (unload) the userform and voila.


"kind of like you see on the web all the time. "

Unfortunately. I would hate to see Word become remotely like the web.
However, it is almost there. Again, unfortunately.

But can Word display images in a -sort of - popup. Yes, on a userform.
 
M

mat

"Documents are not the dead things they used to be."

Oh, but how I wish they were. I wish that Word (an excellent word-processor)
was not being used as if it is a browser, or a data source like a spreadsheet,
or a layout application.....etc. etc.

True, Word has many capabilities beyond word-processing. I sincerely wish
they were ALL removed.


"additional images available to the reader which open as popup images
when a link is clicked"

I am not sure what you mean by "additional". I am also not sure what you
mean by "link is clicked". What link?

Can Word do a - sort of - popup with an image in it? Yes. A userform with
an image control on it works fine. It can not be a "link" that shows the
userform,as a hyperlink does not execute instructions. But you could use a
macrobutton, or an ActiveX commandbutton. It depends on what exactly you
want.

The image showing in the Image control can be loaded dynamically depending on
your criteria. That an an OK button to close (unload) the userform and voila.


"kind of like you see on the web all the time. "

Unfortunately. I would hate to see Word become remotely like the web.
However, it is almost there. Again, unfortunately.

But can Word display images in a -sort of - popup. Yes, on a userform.
I can understand your perspective <g>.
 
M

mat

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]}

Thanks Jay for writing that up. I may use that approach but one part of
it that may not suit my need well is having the image file on the disk.
I wonder if there is a way to have a set of embedded images in an array,
that travel with the doc just like any other embedded images, and which
are injected into the userform? Has to be a way but I'm not sure it'd be
worth it. Possibly the simplest route would be to create a userform for
each embedded image, an option I mentioned in the OP.
 
J

Jay Freedman

mat said:
(e-mail address removed) says... [snip]

Thanks Jay for writing that up. I may use that approach but one part
of it that may not suit my need well is having the image file on the
disk. I wonder if there is a way to have a set of embedded images in
an array, that travel with the doc just like any other embedded
images, and which are injected into the userform? Has to be a way but
I'm not sure it'd be worth it. Possibly the simplest route would be
to create a userform for each embedded image, an option I mentioned
in the OP.

I've never found a way to use images that aren't disk files -- at least, not
using the image control that comes with Office VBA. That control requires
the use of the LoadPicture function, which in turn accepts only the names of
disk files. I haven't looked for a third-party image control that could use
some other source.

You certainly could create a bunch of separate userforms, if the number
isn't too large.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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