Another Document Map question (Word 2000)

H

Herb

By default the Document Map on/off setting appears to be linked to the
Word application rather than individual documents.

I would find it more convenient to be able to link the status to
individual documents.

Is it possible?

Thank you.

Herbert Eppel
 
S

Stefan Blom

You'll need a way to distinguish a document that should have the
Document Map displayed from one that should not. I guess you could use
a document variable, test its value when a document is opened (or
created), and then act based on the result of the comparison.

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 
H

Herb

You'll need a way to distinguish a document that should have the
Document Map displayed from one that should not. I guess you could use
a document variable, test its value when a document is opened (or
created), and then act based on the result of the comparison.

Thanks for your reply.

I'm not familiar with document variables - perhaps you could provide
some pointers to how I can implement your suggestion?

Thank you.

Herbert Eppel
 
S

Stefan Blom

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
 
H

Herb

However, if you are satisfied with a simple solution, which includes a
document variable and two auto macros, here's how to do it:

Spot on!

This proves that simple solutions are often the best! :)

Thanks for your time.

Herbert Eppel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top