UserForms in document templates

N

natanz

as a matter of design, if you are using a userform to collect some
information that will then be fed into a template, what is the best
approach if someone wants to revise some of that info. Do you bring up
the UserForm again, or do you just leave the user on their own.

In my template i have the user pick a job number, or a job name, and
then fill in the other in some form fields in the document. Once the
userForm is gone, i have disconnected from the data source, so I don't
know how to match data 1 with data 2 without restarting the whole
userform, but that seems like it could be pretty onerous.

any thoughts?
 
C

Charles Kenyon

I restart the userform, picking up the previous answers from the document
where they were inserted. An alternative would be to save document variables
and work with those.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
D

Doug Robbins

Even then, I would load the data stored in the document variables back into
the userform. If it is likely that the data will need to be changed, it is
better to use document variables rather than bookmarks.

--
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
 
N

natanz

i guess i am not sure what you mean by document variables. can you
show me or direct me to a quick example?
 
D

Doug Robbins

Say you have a textbox on the userform with the name of txtFName, then in
the code in the userform that causes the data to be transferred into the
document use

With ActiveDocument
.Variables("varFName").Value = txtFName.Text
.Variables(etc. for the remaining data)



.Fields.Update
End With

In the document you need to have a { DOCVARIABLE varFName } field. The
..Fields.Update statement will cause it to display the data that was entered
into the txtFName textbox.

To reload the data into the userform, in the Initialise event, use

txtFName = ActiveDocument.Variables(varFName).Value


--
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
 
C

Charles Kenyon

I agree, I do repopulate the userform with existing data. Making the user
reenter everything to make a few changes makes for very unhappy users. My
primary userform is set to glean data from other files (at styles) and
insert the data into the new file at the same styles so I use the same code
to pull it back out. Otherwise, I use document variables and fields.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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