User Forms with Option Groups

D

D Collins

Hello,

I have a user form that I created with an option group of
5 choices and several text boxes. I would like the user
to be able to reopen the user form down the road and have
it repopulate the user form with the data that is in the
document.

I know how to pass the data from the document back to the
text boxes in the form, but how do I pass the choice they
had originally made, out of the 5 options they had to
choose from, back to the user form? By the way the
choices insert a multi-line address based on their
location.

Thanks, D.
 
D

Doug Robbins - Word MVP

Easiest way is to store the choice as a document variable and then retrieve
that variable when the form is re-loaded.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
D

D Collins

I may be a little green in this area, but doesn't the
object variable get destroyed when the procedure ends?
Do I have to do something for it to retain its value
between calls to the form?

Thanks.
 
P

Peter Hewett

Hi D Collins

Doug said use a Document Variable. These are not instantiated VBA object variables per
se. These are variables that are part (or become part of) the document metadata. You
create and use a document variable something like this:
ActiveDocument.Variable("MyDocVar").Value = "This is the doc var text"
MsgBox ActiveDocument.Variable("MyDocVar").Value

Since these are part of the document they are persisted with the document and thus
available at any time (unless you delete it of course).

HTH + Cheers - Peter
 

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