atw: Re: DocVariables in Word
- From: "Partridge, Robert" <Robert.Partridge@xxxxxxxxxxxxx>
- To: <austechwriter@xxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 14:37:48 +1100
It was a new one on me too. Interesting things. The VB help tells you
how to add and display them. In a document, you can use the {
DOCVARIABLE "Name" } field to display them but they can only be
set/reset from VB.
From the VB help on the Variables property:
---------
Example
This example adds a document variable named "Value1" to the active
document. The example then retrieves the value from the Value1 variable,
adds 3 to the value, and displays the results.
ActiveDocument.Variables.Add Name:="Value1", Value:="1"
MsgBox ActiveDocument.Variables("Value1") + 3
This example displays the name and value of each document variable in
the active document.
For Each myVar In ActiveDocument.Variables
MsgBox "Name =" & myVar.Name & vbCr & "Value = " & myVar.Value
Next myVar
---------
So I guess to change a value you'd need to find out the name of the
variable and then attach a bit of code to the doc with something like:
Sub changeVariables()
ActiveDocument.Variables("variablename") = "something new"
End Sub
Help you any?
Rob
________________________________
From: Elizabeth Fullerton
We have a document which uses DocVariable fields. We don't know how to
change the value of them, and we want to. Hopefully someone can help me,
otherwise I am in for an afternoon of playing!
**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx
To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.
To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with
"unsubscribe" in the Subject field.
To search the austechwriter archives, go to
www.freelists.org/archives/austechwriter
To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************
Other related posts: