CommandBar, template, document, scope

S

Scott Ribe

Assume a template which puts up a custom toolbar for its document. Given two
different documents based on the same template, open at the same time, how
do I either

- have each document own an instance of a toolbar with only the toolbar
instance of the active document displayed at any time, or

- have a single instance of the toolbar, and update some of its controls to
reflect the state of the active document.

I've played around with this, and have found:

- if each document is created from its own (identical) copy of the template,
it just works as I want, but I really can't create a template per document,

- if each document creates its own toolbar, both toolbars are displayed
whenever either document is displayed, even though I attempt to associate
them with their documents as: ActiveDocument.CommandBars.Add,

- I find no mention in the documentation of an Activate event for a window
or document that I could trap in order to adjust the toolbar display

So far, the only thing I've been able to figure out that might work is to
use the Application's OnTime event to continuously check which document is
active.

On the other hand, perhaps a non-modal floating UI is not a practical
possibility and I have to go back to a user form...
 
S

Scott Ribe

You could simulate a Document_Change() event using the technique here:

Thanks much.

I'm not sure I need to simulate anything; I just need to use the
DocumentChange event. I kept searching on "activate" and "activation", and
reading about document & window events, and never found this.

At the same time, I'm also looking at putting all my code into a separate
Cocoa app which floats a utility window alongside the Word window. I'm
leaning toward this because it gives me more complete access to modern UI
stuff, and puts more of the programming in a language that I know better.
But even then, the DocumentChange event will be quite useful because it will
still let me avoid polling Word continuously to observe the active document,
whether I'm doing it from VBA or a separate process.
 
J

JE McGimpsey

Scott Ribe said:
I'm not sure I need to simulate anything; I just need to use the
DocumentChange event. I kept searching on "activate" and "activation", and
reading about document & window events, and never found this.

Probably not. I've found it more useful to handle document_change within
a class in a global template, but I also generally differentiate between
New/Change/Close.
 

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