Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA paste image from userform to WORD doc

456 views
Skip to first unread message

Kernal

unread,
Aug 15, 2003, 10:26:39 AM8/15/03
to
Here is what I want to do:

I have a userform that opens by use of a command button
which is in a table in a WORD document.

The userform contains multiple pictures and corresponding
option buttons, and an OK and Cancel command button.

I want to be able to select one picture and click OK and
have the picture pasted into the bookmarked cell on the
WORD table.

My pictures are on image boxes. Am I better off putting
pictures on the option buttons?

I will have many cells with different pictures on the
document.

Mark Tangard

unread,
Aug 16, 2003, 2:24:15 AM8/16/03
to

I don't believe it matters where you place the images on
the userform, because I'm pretty sure you can't access
those images via code, that is, to copy them from there
to a document.

What I'd do is make an AutoText from each image (insert
it inline into a Word doc, I mean, then make an AutoText
from that 'character'). Then have the code for OK button
look to see which option button is checked and insert the
corresponding AutoText in the document, something like
this (note: untested code):

Dim r As Range, t as Table
Set t = ActiveDocument.Tables(1)
Set r = t.Cell(3,3).Range
r.MoveEnd wdCharacter, -1 'Avoid the cell-end marker
ThisDocument.AttachedTemplate. _
AutoTextEntries("alex").Insert Where:=r

HTH.

--
Mark Tangard <Ma...@Tangard.com>, Microsoft Word MVP
Please reply only to the newsgroup, not by private mail.
Note well: MVPs do not work for Microsoft.
"Life is nothing if you're not obsessed." --John Waters

Kernal

unread,
Aug 18, 2003, 11:11:01 AM8/18/03
to
I tried the AutoText code, but when I
select "AttachedTemplate" it gives me an error. How do I
fix that? I've been trying an assortment of codes using
the help menu, but I can't get anything with AutoText to
work.
ex

Private Sub cmdOK_Click()

Dim opt As OptionButton
Dim cmd As CommandButton
Dim myform As New myform
Dim r As Range
Dim t As Table

Set t = ActiveDocument.Tables(1)

If optOptionButton2.Value = True Then

Set r = t.Cell(2, 5).Range
r.MoveEnd wdCharacter, -1
ThisDocument.AttachedTemplate.AutoTextEntries
("picture_2").insert where:=r


End If

Unload Me

End Sub

???????????????????????

THANKS!!!!!!!!!!!

>.
>

Darren Carter

unread,
Aug 20, 2003, 5:05:08 AM8/20/03
to
I have needed to do the exact same feature in my Word
document that you have required. I have now managed to
crack it! If you want a copy of the Word document then let
me know and you can use the code for completing it in your
document.

Darren

>.
>

Kernal

unread,
Aug 21, 2003, 11:21:03 AM8/21/03
to
Here is how to do it. Much thanks to Darren for help.

NormalTemplate.AutoTextEntries("text").insert
where:=ActiveDocument.Bookmarks("bm").Range

>.
>

0 new messages