Insert UserForm Image

J

Jack

I am creating a dynamic userform. Is there anyway I can do to get a picture
from the current(active) word document and insert it into the userform? If it
is possible, how can do it? If it is impossible, is there anyway I can work
around?

Thank you for your help.
 
J

Jay Freedman

I am creating a dynamic userform. Is there anyway I can do to get a picture
from the current(active) word document and insert it into the userform? If it
is possible, how can do it? If it is impossible, is there anyway I can work
around?

Thank you for your help.

Someone else may prove me wrong, but I don't think it's possible. The help topic
for the Image control's .Picture property says:

"While designing a form, you can use the control's property page to assign a
bitmap to the Picture property. While running a form, you must use the
LoadPicture function to assign a bitmap to Picture."

The syntax for the LoadPicture function says that it requires a parameter which
is "The full path to a picture file" -- that is, the picture must reside in a
disk file, not embedded in a document.

The only method I can suggest is to arrange your setup so the pictures in the
document are linked from disk files (using IncludePicture fields), so the
userform can extract the file path from the field for use in the LoadPicture
function.
 
J

Jack

Thanks a lot. To be honest, I have been looking for work around for a long
time. Here is another idea, but I don't know if it is feasible with VBA. Is
it possible for me to extract the image in the active document and save it in
a temporary file (with jpg or other image file extension) in the hard disk.
Then I can load this image onto the Userform using LoadPicture method. After
that, I will delete the temporary file stored on the hard disk.

Is it possible to do this using VBA? If it is possible, how is the code
going to look like? Thanks in advance.
 
J

Jay Freedman

Thanks a lot. To be honest, I have been looking for work around for a long
time. Here is another idea, but I don't know if it is feasible with VBA. Is
it possible for me to extract the image in the active document and save it in
a temporary file (with jpg or other image file extension) in the hard disk.
Then I can load this image onto the Userform using LoadPicture method. After
that, I will delete the temporary file stored on the hard disk.

Is it possible to do this using VBA? If it is possible, how is the code
going to look like? Thanks in advance.

Yes, that might be possible. Download the demo file from
http://www.lebans.com/msword.htm and try the code in it. It will save the
contents of the clipboard to a disk file. I think it could be adapted to do what
you described, though I haven't looked at it closely enough to tell you exactly
how.
 

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