none
Which call back function or event handler will be called...? RRS feed

  • Question

  • hi again,

    in my word vsto add-in program which contains a custom ribbon tab additional to office built in tabs. Here, when a user head to open existing document or create a new document by clicking the File Tab my custom tab and the other mso ribbons get invisible. At this point, in my ribbon program i want to do a specific work like hiding custom window which was presented to the user as result of choosing a custom checkbox. I don't know which event of microsoft.office.interop.word namespace will be triggered or which call back called. tried getVisible call back function of <tab> tag, no result. 

    Can someone point me to the correct callback function or event handler to use when the user presses the built- in File tab.

    Saturday, February 6, 2016 1:38 PM

All replies

  • Hi,

    maybe you could use Application.DocumentOpen. Like this:

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
    	this.Application.DocumentOpen += Application_DocumentOpen;
    }


    Sunday, February 7, 2016 5:00 PM
  • actually my question related to office backstage view tab (File) which can only handled or modified by the <backstage> tag of <customUI>  which is not usable from within the ribbon.cs and ribbon.xml as far as i understood. or it is possible. need more guidance.
    Monday, February 8, 2016 3:16 AM
  • Hi,

    I am not able to understand the secnario exactly. Did you want to show you custom ribbon only when a new document created or opened?

    If I understood correctly, we can use IRibbonUI.Invalidate to trigger the call back of the ribbon. And we can add this mehoed to NewDocument and DocumentOpen event. More detail about this function please refer to link below:

    IRibbonUI.Invalidate

    If I misunderstood, please feel free to let me know.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 9, 2016 1:45 PM
    Moderator
  • the backstage view of word triggers (calls) onShow and onHide callbacks whenever it is opened or closed by clicking File tab or back button. Here, how i can avail these callbacks in ribbon.cs to be notified of it. i placed <backstage> </backstage> tags in ribbon.xml but those callbacks i given in them were not invoked. 

    i hope you understood the situation, have any suggestions.

    Wednesday, February 10, 2016 6:41 AM
  • Hi Karrem,

    The onShow and onHide callbacks only fired when we switch the backstage view of Office. Are you failed to fire this event when you open or close the backstage view? If I understood correctly, here is the sample callback for your reference:

     public void onShow(object contextObject)
            {
                MessageBox.Show("My onShow Action!");
            }

    And for trigger the other callback for the control on the backstage view we can use IRibbonUI.Invalidate . For example, there are two buttons on the backstage view. We want to hide/show one button via clicking anther button.

    Here is the ribbon XML and callback for your reference:

    <backstage onShow="onShow">
      <button id="refreshUI"
              label="refreshUI"
              onAction="refreshUI"/>
      <button id="buttonVisible"
              label="buttonVisible"
              getVisible="IsVisble"/>
    </backstage>
    Callback:
       public void refreshUI(IRibbonControl control)
            {
                ribbon.Invalidate();
            }
            
                 bool visible;
            public bool IsVisble(IRibbonControl o)
            {
               visible = !visible;            
               return visible;
            }
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, February 15, 2016 5:44 AM
    Moderator
  • sorry Fei Xue for late responding,

    in my word add-in, as already said, i've placed check boxes which individually opens a child window for the word document which keeps open until the corresponding check box unticked. in between, when user opens the backstage view, the child window has to minimize or hide, this is the desired action to perform. 

    i did placed the <backstage> tag in my ribbon.xml and placed onShow callback but no result. that call back function never get invoked. so i thought this is wrong approach to place <backstage> tag in ribbon.xml. so, need suggestions on any other approach...

    if possible, please provide complete .xml program which contains the required tags.

    Wednesday, March 2, 2016 6:31 AM
  • Hi Karrem,

    Here is the complete ribbon XML for your reference:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
      <backstage onHide="onHide" onShow="onShow"></backstage>
    </customUI>

    You can add some custom group to see whether the custom ribbon was loaded by Word application. If not, please check whether you have override the CreateRibbonExtensibilityObject function in the ThisAddIn.cs.

    And here is the sample method for your reference:

      protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
            {
                return new Ribbon1();
            }
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 4, 2016 8:54 AM
    Moderator
  • hi Fei Xue...

    sorry for stretching this thread issue. 

    In my add-in i've already overridden CreateRibbonExtensibilityObject function to return my Ribbon class instance to office. Here, if i again add a new ribbon item , to operate with backstage view, in addition to existing one, i must have to override the same member in  ThisAddIn.cs which is not possible. 

    Saturday, March 5, 2016 1:13 PM