View Single Post
 
Old 09-13-2015, 01:09 AM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can add/query document Variables quite easily with VBA. For example:
Code:
Sub Demo()
With ActiveDocument.Variables
  If .Item("MyVar") Is Nothing Then .Add Name:="MyVar", Value:="MyVal"
  MsgBox .Item("MyVar").Value
End With
End Sub
You can then use a DOCVARIABLE field in the document to retrieve its value.

Word's custom document properties are about as easy to work with, but built-in document properties require less work, since you always know they'll be there. Both kinds can also be viewed via File>Info>Properties and can be referenced in the document via a DOCPROPERTY field.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote