Search code examples
ms-wordword-2010word-2007ribbonxword-2013

dynamically enable or disable custom ribbon buttons


I have added custom ribbon button to word 2010 using ribbon xml.
I want to disable ribbon buttons when document is protected or read only and when user removes protection want to reenable these buttons.

Unfortunately I am not getting any event for Ribbon tan click or document properties change, so what should I do?


Solution

  • You may find the ProtectedViewWindowBeforeEdit event of the Application class which is fired immediately before editing is enabled on the document in the specified protected view window.

    Be aware, the Fluent UI (aka Ribbon UI) is based on the callbacks. You can read more about the ribbon controls in the following series of articles in MSDN:

    Use callbacks to get notified when the tab is going to be shown (clicked).