Solved

Save a string into a Form of MS Word Document

Posted on 1999-01-04
8
166 Views
Last Modified: 2010-05-03
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.
0
Comment
Question by:st
  • 4
  • 4
8 Comments
 
LVL 4

Expert Comment

by:mcix
ID: 1453899
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
 
LVL 1

Author Comment

by:st
ID: 1453900
But.. How can I change the content of "TEST" ?
Thanks.
0
 
LVL 4

Expert Comment

by:mcix
ID: 1453901
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
 
LVL 1

Author Comment

by:st
ID: 1453902
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:mcix
ID: 1453903
I finally got around to answering your other question...

Sorry about the delay.


0
 
LVL 1

Author Comment

by:st
ID: 1453904
mcix, I would like to give the points and save this question with your comment. Could you please give a help? Thank you.
0
 
LVL 4

Accepted Solution

by:
mcix earned 20 total points
ID: 1453905
Did the solution work for you?
0
 
LVL 1

Author Comment

by:st
ID: 1453906
Sure! Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now