none
How to get OnNavigate event in OneNote 2010 addin RRS feed

  • Question

  • Hi,

    I'm developing a OneNote 2010 addin. I follow Malte's tutorial and build my first project successfully, but get stuck when trying to make it a little more complex.

    I want a function to be called when OneNote UI is navigated away from current page. My code is:

                   

    public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
    {
                onApp = (OneNote.ApplicationClass)Application;
                try
                {
    onApp.OnNavigate += new Microsoft.Office.Interop.OneNote.IOneNoteEvents_OnNavigateEventHandler(OnNavigate);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
    }

    public void OnNavigate()
    {
    MessageBox.Show("test!");
    }

    I get the exception message: "Error HRESULT E_FAIL has been returned from a call to a COM component.", and function OnNavigate() doesn't work.

    Does anyone know how to solve this problem? Or, is there other ways to get the navigate event?

    Thank you.

    Wednesday, May 9, 2012 8:51 AM

Answers

All replies

  • Hi Ross,

    Thanks for posting in the MSDN Forum.

    I can reproduce you issue. I will involve some experts into this issue to see whether they can help you out. There might be some time delay, appreciate for your patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, May 14, 2012 2:07 AM
    Moderator
  • Hi Ross,

    The OneNote object model doesn't support event in *managed* code, you may have to register the event in C++.

    Refer to: http://msdn.microsoft.com/en-us/library/gg649853.aspx

    best regards,


    Forrest Guo | MSDN Community Support | Feedback to manager

    Monday, May 14, 2012 7:03 AM
    Moderator
  • HI,

    Has Anybody tried with registering events in one note addin developed in c++.

    I have tried registering events in Office 2016 in c#,it works but I get delayed response for the actions performed.

    As mentioned in the documentation i.e. events are not supported in managed code so can I get the sample to

    register events in cpp.

    Any help will be appreciated.

    Thanks,

    Vinod

    Tuesday, July 18, 2017 10:42 AM