Results 1 to 2 of 2
2003-01-02, 11:17 #1
- Join Date
- Mar 2002
- Sydney Australia
- Thanked 0 Times in 0 Posts
Saving variable values when template closes (Word 2000)
I set two string values as variables through use of InputBox. For example:
sNameOne = InputBox etc etc
sNameTwo = InputBox etc etc
I want these values to be saved when the document (and the template behind it that contains the macro) close. The intent is that when the macro in the template is next called, the variables will contain the user's preferred (or at least last used) values.
I have read the Word 2000 VBA Help topic "Storing values when a macro ends". The first method proposed - "Document variables" - looks to be the ideal solution. However despite a number of attempts, I am unable to work out how to implement this on the basis of the examples provided. For example, the Help suggests
ThisDocument.Variables.Add Name:="Age", Value:=12
I don't see how I am to specify what follows "Value:=" when it could be whatever the user has entered through the InputBox.
Clearly, I am groping in a fog, and I would be most appreciative if someone could point me in the right direction.
2003-01-02, 11:30 #2
- Join Date
- Nov 2001
- Thanked 7 Times in 7 Posts
Re: Saving variable values when template closes (Word 2000)
You could try ActiveDocument.Variables.Add Name:="NameOne", Value:=sNameOne
You also need to be able to handle the case where the variable has already been added and you are just changing the value.