Save a string into a Form of MS Word Document

I have a MS Word document which contain a Form for allow user to input a Directory Path.

How can I save the "Directory Path" into the Form's text box control (or somewhere) after user did the entry? So that user don't need to type the "Directory Path" again next time.

Thanks a lot.
LVL 1
stAsked:
Who is Participating?
 
mcixCommented:
Did the solution work for you?
0
 
mcixCommented:
You may want to consider using the Variables collection of the Document Object.

Something Like this...

Private Sub Document_Open()
    Dim mstrCurrentPath As String
    ActiveDocument.Variables.Add "TEST", "SOME VALUE"
    mstrCurrentPath = ActiveDocument.Variables("TEST")
    MsgBox mstrCurrentPath
End Sub

Hopefully that will point you in a productive direction...

0
 
stAuthor Commented:
But.. How can I change the content of "TEST" ?
Thanks.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
mcixCommented:
Once you create the variable called TEST

You retrieve the value like this:
CurrentValueOfTest = ActiveDocument.Variables("TEST")

You can set the value like this:

ActiveDocument.Variables("TEST") = "Some new Value"

Does that help?

0
 
stAuthor Commented:
Yes! Thanks a lot! But now, I got further problems about these: I can't access the variable when it is a Gobal Template.

I posted this problem as "VBA: Store & Read Variables in a Gobal Template", could you please help me to solve this further question?

Many thanks.

0
 
mcixCommented:
I finally got around to answering your other question...

Sorry about the delay.


0
 
stAuthor Commented:
mcix, I would like to give the points and save this question with your comment. Could you please give a help? Thank you.
0
 
stAuthor Commented:
Sure! Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.