This could be a rather complex task (at least for me). It's not the
creation of document variables that is difficult. Rather, the
difficult part is to detect when documents are closed, opened, and
created. You'd better ask in a programming newsgroup for assistance.
However, if you are satisfied with a simple solution, which includes a
document variable and two auto macros, here's how to do it:
To create the document variable: Press Alt+F11 to display the Visual
Basic Editor. Click Ctrl+G to display the Immediate Window. Type:
ActiveDocument.Variables.Add "ShowDM", "yes"
and press Enter.
Repeat this to create the variable in additional documents. (If you
add the variable in a template, all documents created from that
template inherits it.)
The following macros (stored in normal.dot) looks for the document
variable when a document is opened or created:
Sub AutoOpen()
Dim v As Variable
For Each v In ActiveDocument.Variables
If v.Name = "ShowDM" Then
If ActiveDocument.Variables("ShowDM") = "yes" Then
ActiveWindow.DocumentMap = True
Else
ActiveWindow.DocumentMap = False
End If
Exit Sub
End If
Next v
ActiveWindow.DocumentMap = False
End Sub
Sub AutoNew()
Dim v As Variable
For Each v In ActiveDocument.Variables
If v.Name = "ShowDM" Then
If ActiveDocument.Variables("ShowDM") = "yes" Then
ActiveWindow.DocumentMap = True
Else
ActiveWindow.DocumentMap = False
End If
Exit Sub
End If
Next v
ActiveWindow.DocumentMap = False
End Sub
If you need installation instructions, see
http://gmayor.com/installing_macro.htm.
Note that the above macros do not detect when a different document
is activated (for example, because you closed the current document).
To take care of that, I believe you would have to make use of
Application events.
Again, a programming newsgroup is the best place to get assistance
with this.
--
Stefan Blom
Microsoft Word MVP
in message