views:

245

answers:

1

I have a Word 2003 .dot template that changes its menu based on the condition of the active document.
The DocumentChange, DocumentOpen and NewDocument events of Word.Application trigger setting the .Visible and .Enabled properties of CommandBarButton controls.

On switching active documents, controls exposed by changing the Visible property display correctly, but text buttons which have been enabled/disabled do not change appearance. You can show enabled controls by hovering over them, but the disabled ones do not repaint until you place a window in front.

Is there a simple way to send a repaint message to the menubar, to simulate hiding and exposing?

+1  A: 

You are playing with the visible & enabled properties of the controls. But did you try to hide/unhide the whole commandbar to refresh it?

application.CommandBars.ActiveMenuBar.visible = false
application.CommandBars.ActiveMenuBar.visible = true
Philippe Grondier