Solved

Save a string into a Form of MS Word Document

Posted on 1999-01-04
8
165 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

13 Experts available now in Live!

Get 1:1 Help Now