none
NavigationPane.ModuleSwitch event triggering only once? RRS feed

  • Question

  • Hi all,

    My NavigationPane.ModuleSwitch  event triggers only once.  Why does this happen?

    I have this code in the start up for my addin:

    explorer = Globals.ThisAddIn.Application.ActiveExplorer();
                    explorer.NavigationPane.ModuleSwitch += new NavigationPaneEvents_12_ModuleSwitchEventHandler(NavigationPane_ModuleSwitch);

    And the event handler:

     public void NavigationPane_ModuleSwitch(NavigationModule CurrentModule)
            {
                if (CurrentModule.Name == "Mail")
                {
                    MessageBox.Show("test1");        
                }
                else if (CurrentModule.Name == "Solutions")
                {
                    MessageBox.Show("test2");    
                }
            }

    It triggers only for the first time when I switch to the other module. And then never triggers. What am I doing wrong?


    Thanks Prashanth

    Tuesday, June 12, 2012 7:33 AM

Answers

  • usually this means that you are not storing anywhere object on which you attached to events and it goes out of scope in .net. Show us code where yu attach to ModuleSwitch event and where you store NavigationPane instance on which you did it.

    Tuesday, June 12, 2012 8:46 AM
  • accessing ribbon variable does not give you any function to invoke to change current tab, sorry :-)

    Either:

    1. do it by send keys

    2. add your controls to main Home tab

    3. create custom pane and this can be shown/hidden programmatically.

    Tuesday, June 12, 2012 10:16 AM

All replies

  • usually this means that you are not storing anywhere object on which you attached to events and it goes out of scope in .net. Show us code where yu attach to ModuleSwitch event and where you store NavigationPane instance on which you did it.

    Tuesday, June 12, 2012 8:46 AM
  • Thanks Damian! Got it working.

    Also, this is a different question - but, I want to select a tab in the ribbon on module switch. Is there a way better than Sendkeys?


    Thanks Prashanth


    Tuesday, June 12, 2012 8:58 AM
  • tab in ribbon where? in explorer window?
    Tuesday, June 12, 2012 9:18 AM
  • Yes, in the explorer window.

    Thanks Prashanth

    Tuesday, June 12, 2012 9:22 AM
  • i do not think so, so try out sendkeys, but remember to check if some tabs are added in the middle, or removed (for example by other add-in) if shortcut letters do not change.
    Tuesday, June 12, 2012 9:29 AM
  • Yeah, that is exactly why I do not want to use SendKeys.

    Can't we just get the control of the ribbon and then select the tab?


    Thanks Prashanth


    Tuesday, June 12, 2012 9:47 AM
  • if you know of a way to do it, sure. Also share it here for others to know.

    Tuesday, June 12, 2012 10:01 AM
  • I wish. Actually, thats what I have been asking for in the other thread (http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/8b48b34e-5490-4b82-8c9b-22db8ac59350). You have given me some solution there. How is that?


    Thanks Prashanth


    Tuesday, June 12, 2012 10:11 AM
  • accessing ribbon variable does not give you any function to invoke to change current tab, sorry :-)

    Either:

    1. do it by send keys

    2. add your controls to main Home tab

    3. create custom pane and this can be shown/hidden programmatically.

    Tuesday, June 12, 2012 10:16 AM
  • Custom pane appears where in Outlook?


    Thanks Prashanth

    Tuesday, June 12, 2012 10:27 AM
  • right hand side, where you have task list, calendar, frequent contacts, collapsible panel.
    Tuesday, June 12, 2012 10:37 AM
  • The ribbon interface for Office 2010 and later does provide methods for setting the current ribbon tab: ActivateTab(), ActivateTabMso() and ActivateTabQ(). Unfortunately Office 2007 doesn't have any of those methods on the IRibbonUI interface.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:c5134abd-f91c-4334-9fea-a6adaf637731...
    right hand side, where you have task list, calendar, frequent contacts, collapsible panel.

    Ken Slovak MVP - Outlook
    Tuesday, June 12, 2012 3:52 PM
    Moderator
  • The ribbon interface for Office 2010 and later does provide methods for setting the current ribbon tab: ActivateTab(), ActivateTabMso() and ActivateTabQ(). Unfortunately Office 2007 doesn't have any of those methods on the IRibbonUI interface.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:c5134abd-f91c-4334-9fea-a6adaf637731...
    right hand side, where you have task list, calendar, frequent contacts, collapsible panel.

    Ken Slovak MVP - Outlook
    That is awesome news, because I am using Outlook 2010 ~! Thanks Ken

    Thanks Prashanth

    Wednesday, June 13, 2012 5:31 AM