none
Handling Word 2013 File Menu event or Backstage show event RRS feed

  • Question

  • How does one catch the Word 2013 File menu event that occurs when a user clicks the File menu? I ask because I need to modify the backstage some when when one of my documents is being used (I have custom Properties in my documents as an ID of my documents). Do I use a Backstage show event instead and if so what is the ID for that and are there examples of catchingthe File menu event or Backstage show event?

    Thank you

    Monday, April 1, 2013 3:29 PM

Answers

  • OK, I've fixed those links. For some reason, the automatic link generator dropped the closing parentheses <sigh>. If you'd tried copy/pasting the link TEXT into a browser it should have worked.

    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by JimBassett Monday, April 1, 2013 5:33 PM
    Monday, April 1, 2013 5:10 PM
    Moderator

All replies

  • Hi Jim

    The Backstage is part of the Ribbon XML. As such, there are no "events", only callbacks you define in your Ribbon XML. Your first stop for anything involving the RIbbon is:

    http://msdn.microsoft.com/en-us/office/aa905530.aspx

    There are two articles there specifically about working with the BAckstage:

    http://msdn.microsoft.com/en-us/library/ee691833(v=office.14)
    http://msdn.microsoft.com/en-us/library/ee815851(v=office.14))

    There you'll find information about the onShow attribute of the <backstage> element. That callback allows you to perform actions when the Backstage come into or goes out of focus.


    Cindy Meister, VSTO/Word MVP, my blog


    Monday, April 1, 2013 4:17 PM
    Moderator
  • Thank you Cindy. The last two links do not work and return a page with the following.

    Content not found

            We could not find the page you requested.

    Monday, April 1, 2013 4:28 PM
  • Thank you Cindy. The last two links do not work and return a page with the following.

    Content not found

            We could not find the page you requested.

    Well, that's odd because I was ON those pages in order to copy the links from the Address Bar in my browser. They were working fine for me a few minutes ago...

    Cindy Meister, VSTO/Word MVP, my blog

    Monday, April 1, 2013 4:37 PM
    Moderator
  • I have had the samething happen to me when I sent links to someone and then they were not working. I have tried the links again including from another PC and another browser and still those links don't work.They also don't work from Smart Phone browser.
    Monday, April 1, 2013 5:04 PM
  • Weird...

    If the first one works, it's the first two articles in the section Backstage View/Articles.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, April 1, 2013 5:08 PM
    Moderator
  • OK, I've fixed those links. For some reason, the automatic link generator dropped the closing parentheses <sigh>. If you'd tried copy/pasting the link TEXT into a browser it should have worked.

    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by JimBassett Monday, April 1, 2013 5:33 PM
    Monday, April 1, 2013 5:10 PM
    Moderator
  • Thank you Cindy!
    Monday, April 1, 2013 5:33 PM
  • Looks like callbacks are not allowed to be used with built in Tabs

    Wednesday, April 10, 2013 7:39 PM
  • Jim,

    A little warning about using the onShow callback in the backstage. Below is from an old thread here on this forum. It's still not fixed in Office 2016.

    Regards,
    Lars-Eric

    -----------------------------------------------------------
    Hello Bruce and thanks for your reply.

    The onLoad attribute in the <customUI> tag is no problem. It's the onShow attribute in the <backstage> tag. The onShow callback seems to be called on the activedocument (which can be just any document) each time you enter the backstage. That is the problem.

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnLoad">
     <backstage onShow="OnShow">

    Can you make a very simple test?

    Add this code to a new document:

    '----------------------------------
    Dim oRibbon As IRibbonUI

    Public Sub OnLoad(oBS As IRibbonUI)
       
        Set oRibbon = oBS
    End Sub

    Public Sub OnBackstageShow(oBS As Object)
       
        MsgBox "You are entering the Backstage"
       
        'oRibbon.Invalidate
       
    End Sub
    '----------------------------------

    Save the document as a macro enabled dokument. Start the tool you use to add the XML for the RibbonUI and open the document. Add this very basic XML to the document:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnLoad">
      <backstage onShow="OnBackstageShow">
      </backstage>
    < /customUI>

    Save the document.

    Now, open the document in Word. Click on the File tab and you should see the message "You are entering the Backstage". So far no problem. Then create a new empty document and make sure the new document has focus. Click on the File tab again. I get an error message telling me that the macro is not available, as the Backstage seems to try to call the OnBackstageShow callback in the new document which is not present  as it has no macros at all. This is a little bit in contradiction to what you said in your reply, 'each file has it's own custom UI' and is in a way a show stopper. There seems to be something wrong in the design of the backstage about the onShow callback and I hope the developers can fix this soon. The use of <backstage onShow="xxx"> is documented in examples on the MSDN site and it works as intended as long as you have only one document open. In my oppinion the onShow callback should only be called on the document that is the container for the modified Backstage.

    The same thing happens in Excel.

    Friday, October 23, 2015 10:12 AM