Hi Chip,
Doc Variables can be in both templates and documents.
But, if you create them in a template, and then create a doc based on that
template, your "template doc variables" will also be in the document. I use
that all the time.
For example, sometimes I need to know if a document has been saved at least
once. The first time it is saved, I run a set of macros, and after that a
different set. For that, I create a doc variable in the template with a
value "x", then when the user saves the document, I check the doc variable
value, if it is equal to that of the value in the template - "x" in this
case - (i.e it has not been changed) then this is a first time save. I then
run the "first-time-save" macros and at the end change that doc variable
value to "y", for example. So, the next time the doc gets saved, the doc
variable is now equal to "y", which allows me to run a set of different
macros.
unless I open it as a document I'm unable to use them directly in the
template.
What are you trying to do exactly?
This
'_______________________________________
ScreenUpdating = False
With ActiveDocument.AttachedTemplate.OpenAsDocument
.Variables("UserName") = Application.UserName
.Close SaveChanges:=wdSaveChanges
End With
ScreenUpdating = True
'_______________________________________
will manipulate doc variables in the attached template, but will have no
impact in the active document.
Or this
'_______________________________________
Documents("MyDocument.doc").Variables("UserName") = Application.UserName
'_______________________________________
will manipulate variables in an open document.
HTH
--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org
"Chip Orange" <
[email protected][remove-me-and-brackets]> a écrit
dans le message de news: (e-mail address removed)...
I'm trying to use document variables with the normaltemplate object, and I
thought I read that variables existed in both templates and documents; yet,
unless I open it as a document I'm unable to use them directly in the
template.
Did I just mis-interpret the documentation on document variables, are they
only available in documents?
thanks.
Chip