Customized the Office 2010 Backstage View

Answered Customized the Office 2010 Backstage View

  • jeudi 19 juillet 2012 13:15
     
      A du code

    I have created an MS Word 2010 Back Stage UI using this tutorial

    http://msdn.microsoft.com/en-us/library/ff936212.aspx#Y1168

    In my Back stage UI the XML file is like this.

    <?xml version="1.0" encoding="utf-8" ?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
      <backstage>
        <button id="FSConvertor" insertAfterMso="TabInfo" label="Convert FS To MS Word" imageMso="FileSaveAs" onAction="OnAction" isDefinitive="true" />
      </backstage>
    </customUI>

    Now I want pass the location of currently opened document onto this plugin and I want this UI to be disabled. It should be enabled only when someone opens a file name with .ODT extension within the MS Word 2010. How can I accompalish this?

    Thanks in Advance.


    Adeel


Toutes les réponses

  • vendredi 20 juillet 2012 13:40
    Modérateur
     
     Traitée

    Hi Adeel

    It would probably be best for your Com Add-in to monitor the Word Application's DocumentChange event. After this event fires, the Application.ActiveDocument is the currently active document. So you can extract the extension from ActiveDocument.Name to determine whether the <button> should be enabled or disabled.

    For this, you need to include the getEnabled attribute in the element. The value assigned to that is the name of a method in your code file that handles the Ribbon callbacks (the same place you have OnAction). The DocumentChange event needs to trigger the InvalidateControl method for the RibbonUI. That will cause the <button> element to re-evaluate all its callbacks, such as getEnabled. The callback will evaluate the file name of the ActiveDocument and set the return value for the callback to either true or false, as required.

    For more information on using callbacks and InvalidateControl, please consult the three-part article on customizing the Ribbon UI. Link for Part 1: http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx


    Cindy Meister, VSTO/Word MVP

    • Marqué comme réponse maverick786us mardi 24 juillet 2012 10:43
    •  
  • lundi 23 juillet 2012 08:59
    Modérateur
     
     

    Hi Adeel

    As you've posted a new question about handling events - which I've moved to the more appropriate Word for Developers forum - let's follow-up there.


    Cindy Meister, VSTO/Word MVP