none
VSTO - Word - Close backstage view RRS feed

  • Question

  • Hi,

    I'm developing a VSTO Addin for Word 2013 and upon save a user is presented with the backstage view where my event handler is triggered. (ApplicationEvents4_DocumentBeforeSaveEventHandler). Is there an easy way to easily close the Backstage View and return back to the Document View?

    I have been trying with the ActivateTab() and ExecuteMso() but without success. 

    Office Backstage View

    /Adam


    -- Adam Andersson --

    Monday, May 22, 2017 12:50 PM

Answers

  • Hi,

    I use the below however I do not have a custom tab but instead my buttons are placed on the builtin Home tab ("TabHome").

    I use the following call from EventInterface_DocumentBeforeSave function:

    Globals.Ribbons.MyRibbon.RibbonUI.ActivateTab("TabHome");

    All I want is to close the BackStage View and return back to the Document View. The only working approach I have so far is the very ugly one:

    System.Windows.Forms.SendKeys.Send("%");
    System.Windows.Forms.SendKeys.Send("{ESC}");
    System.Windows.Forms.SendKeys.Send("%");
    

    Thanks.


    -- Adam Andersson --




    Thursday, May 25, 2017 9:12 PM

All replies

  • Hello,

    How do you use ActivateTab and ExecuteMso? ExecuteMso only works on controls that are built-in buttons, toggleButtons and splitButtons. ActivateTab activates the specified custom tab. So you could use ActivateTab to activate a custom tab for closing backstage view. Such as.

    <tab id="TestTab" label="TestTab">
          <group id="TestGroup">
            <labelControl id="TestLabel" label="TestLabel"/>
          </group>
        </tab>
    
    Public Sub OnActionTest(ByVal control As Office.IRibbonControl)
            Me.ribbon.ActivateTab("TestTab")
        End Sub
    

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 23, 2017 7:11 AM
    Moderator
  • Hi,

    I use the below however I do not have a custom tab but instead my buttons are placed on the builtin Home tab ("TabHome").

    I use the following call from EventInterface_DocumentBeforeSave function:

    Globals.Ribbons.MyRibbon.RibbonUI.ActivateTab("TabHome");

    All I want is to close the BackStage View and return back to the Document View. The only working approach I have so far is the very ugly one:

    System.Windows.Forms.SendKeys.Send("%");
    System.Windows.Forms.SendKeys.Send("{ESC}");
    System.Windows.Forms.SendKeys.Send("%");
    

    Thanks.


    -- Adam Andersson --




    Thursday, May 25, 2017 9:12 PM
  • Hello,

    For a built-in tab, you could use IRibbonUI.ActivateTabMso Method

    If it doesn't work, please let me know.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, May 26, 2017 6:28 AM
    Moderator
  • Hi,

    Sorry for late reply here. Tested the ActivateTabMso but it doesn't work, nothing happens and the BackStage view is still visible and not closed.

    The call I make is:

    Globals.Ribbons.MyCustomRibbon.RibbonUI.ActivateTabMso("TabHome");

    /Adam


    -- Adam Andersson --

    Wednesday, June 7, 2017 12:19 PM
  • Hi Adam,
    Sorry for late reply, I tried to look for other ways to close the backstage view, but at last I only found Sendkeys that maybe a really easy approach. Even Sendkeys looks ugly but it really works well, right?
    Best Regards,
    Terry
    Tuesday, June 13, 2017 4:44 AM
  • Hi,

    Thanks for looking into it and yes SendKeys works but...you know... :)

    /Adam


    -- Adam Andersson --

    Tuesday, June 13, 2017 5:57 PM
  • Hi Adam,
    I'm glad to hear that Sendkeys can work for you, although it is not perfect. I suggest you mark your solution as the answer to close this thread. Thanks for your understanding.
    Best Regards,
    Terry
    Thursday, June 15, 2017 4:19 AM
  • Faced the same problem. Found a (better) solution posted on StackOverflow:

    https://stackoverflow.com/questions/23120528/programmatically-exit-backstage-view

    Basically you just need to set "isDefinitive" attribute to true if you want to close the backstange when the button is clicked.


    -- Nikolay Belyh, http://unmanagedvisio.com


    Friday, December 6, 2019 12:32 AM