Placement of data from several Userforms in a document

R

RoBo

Who can give me some advice?

I created a template with several Userforms that are linked (you are
directed to the next Userform by clicking the Next button).

How can I gather al the info that a user types and put it in the document
when the last Userform is filled in and the user clicks the Ready button?

Thanks for your help/suggestions. No one in the Dutch User groups has given
any suggestion.

Ron
 
J

Jay Freedman

Opinions vary, but here's mine:

In the template, define a document variable to hold each piece of data the
user will supply. (Document variables can be created only by VBA code; look
at the Help topic on the Variables collection.) In the body of the template,
insert DocVariable fields wherever necessary to display the values of the
variables. Note that you should assign a value, such as a space character,
when you define each variable; otherwise the DocVariable field will show an
error message.

In each userform, as the user clicks the button to go to the next one,
assign the values of the user's data to the proper document variables. When
the last userform is completed, its code should finish with

ActiveDocument.Fields.Update

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

RoBo

Hello Jay,

The template already has bookmarks defined with variable names. Will this
work too or do I have to create fields using the Insert, Field menu in Word
2003?

Ron
 
J

Jay Freedman

You can use the bookmarks, but the code in the userforms will have to be
different. Look at this article:
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.

Another consideration: If you use document variables and DocVariable fields,
you can have two or more fields that display the same variable's value --
you just insert the same field in multiple places. When you use bookmarks,
each bookmark must have a unique name; if you want to repeat a value
elsewhere in the document, you have to use a REF field or a cross-reference
to the bookmark.

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

RoBo

Thanks Jay,

This will most certainly help. Tomorrow I'll implement this and let you know
the results.

Ron
 
M

msteckler

Hello!

I have implemented a similar template. The user enters data in a UserForm,
and then I use :
Private Sub CommandButton3_Click()
With ActiveDocument
.Bookmarks("apartname").Range _
.InsertBefore apartname
End With
ActiveDocument.Fields.Update
UserForm4.Hide

However, the REF fields are NOT being shown in the resulting document. I
have linked them to their respective bookmark, tried updating, but nothing
works.

Any ideas on how this can work?

If this is the worst method, can you recommend a way to use
DocVariables/Properties that will work?

Thank you.

(e-mail address removed)
 

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