Making a UserForm that persists

G

Guest

The way a UserForm behaves is, it appears as you open a document from a
template. The user fills in the blanks, clicks on the commandbutton, and the
data he typed is populated throughout the document.

But if he discovers that he made a typo, there's no way to re-open the
userform and correct his entry...he has to start all over again.

Is there a way around this behavior, ie, a way to have the data he typed,
remain in the userform, and enable the userform to be re-opened and re-edited
unti the user is satisfied?
 
J

Jay Freedman

Bob said:
The way a UserForm behaves is, it appears as you open a document from
a template. The user fills in the blanks, clicks on the
commandbutton, and the data he typed is populated throughout the
document.

But if he discovers that he made a typo, there's no way to re-open the
userform and correct his entry...he has to start all over again.

Is there a way around this behavior, ie, a way to have the data he
typed, remain in the userform, and enable the userform to be
re-opened and re-edited unti the user is satisfied?

Of course there is. It just takes more planning and effort in setting up the
UserForm's code.

A UserForm appears when you open a document, only because there's a macro
named AutoOpen (stored in the document's template) that contains code to
show the UserForm. You can -- in addition or instead -- write another macro
that also shows the UserForm, and assign that macro to a toolbar button or
keyboard shortcut, or you can make it the entry macro of a form field (if
you're using a protected form).

The other part of this is to provide code -- in the launch macro or in the
UserForm's Initialize procedure -- to fill the UserForm's controls with the
data that's already in the document. That way the user can just edit the
specific items that need to change, instead of reentering everything.
Exactly how that code is written depends on how the information is
represented in the document, whether in bookmarks or form fields or document
variables or an external source (e.g., a database).

For specific questions about modifying an existing form, please post in the
newsgroup microsoft.public.word.vba.userforms
(http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.word.vba.userforms).

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