customization context and toolbar button

L

Lina

Hi!
I have made a template that has a custom Toolbar. The Toolbar has some
popupmenus and buttons. One of the commandbarbuttons is calling a macro that
shows or hides a picture in the header. I am now trying to make the button
to toggle so that when the picture is shown the button is pushed or
highlighted, and v v, like the "Track changes"-button. It works fine but the
setting effects the commandbar in all open documents. For exampel:
Document A - picture is shown and button is highlighted
Document B - picture is shown and button is highligheted , so far is
everything ok. Then I presses the button in document B and the picture is
hidden and the button is not highlighted. If I then go back to Document A
the picture is shown but the button is not highlighted which it should be.
I have tryed to set the CustomizationContext but I can´t get it work the
way I want. Can someone please help me?
Many thanks / Lina
 
J

Jezebel

Customization Context won't help. That determines which template the change
is saved in, not which document it applies to. (And be *very* careful using
it: there's a bug in the Customization context that irretrievably corrupts
the active template.)

What you need to do is trap the WindowActivate event (fired, amongst other
causes, whenever you switch between documents), and set the button status
appropriately each time.
 
L

Lina

Thanks ! It works :)
But your answer got me wondering, can you tell me more about that bug in the
customization context?

"Jezebel" skrev:
 
J

Jezebel

I can't remember the exact details, but we had some code along these lines:
set the CustomizationContext to template A; add a toolbar; set the CC to
template B; make a change to the toolbar; set the CC back to template A and
undo the change.

At this point Word would crash and on re-starting on of the templates (can't
remember which one) would be trashed completely.

We didn't research it in detail other than to establish that a) the problem
occurred consistently, and b) it was not an artefact of the templates in
question. (ie we moved the code to another template, and got the same
result).
 
L

Lina

How did you solve your problem? I wonder because I have a set of templates
and every template has a different toolbar that creates when the document
opens. I do not want the different toolbars to exist in every worddocument so
when I create the toolbar i set the customization context to active template
etc. I did this quite resently and after that I have had some problem with
some of the templates. Problems like word crashes totaly when I try to open
them...

I try to with some of my templates but I haven´t figured out what was
causing the problem

"Jezebel" skrev:
 
J

Jezebel

We gave up trying to manipulate toolbars on the fly. We put all the code
into an add-in, and developed a single toolbar which was added manually (to
the add-in).
 

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