Creating a C/C++ Add-In which works with OneNote!

I thought I would take some time today and write up how to program a C/C++ add-in that works with OneNote 2007. Here are the directions I had and downloads below.

  1. Open Visual Studio and create a new C++ project.
  2. For my example I am creating a Win32 Console App:

  3. Now I want to add the OneNote2007 header file, OneNote12.h. You can find that attached with this document. Make sure to copy it to the folder with your C++ source files as well as add it to your header files like this:

  4. Add a new #include for OneNote:


  5. Now just connect to OneNote like you would any other COM API. Please see here for an example:


        IApplication* piOneNote;


        CoCreateInstance(__uuidof(Application), NULL,

            CLSCTX_LOCAL_SERVER, __uuidof(IApplication), (void**)&piOneNote);




            BSTR temp;       

            HRESULT hr = piOneNote->GetHierarchy(NULL, hsNotebooks, &temp);

            wprintf(L“%s”, temp);


A huge thanks to Ilya Koulchin for his help with this, I couldn’t have done this without you!


This should be all that you need to get this working, but if you need anything please let us know!

Comments (9)

  1. basketcase39 says:

    Do you know if something similar can be done with a program written in VB.NET?  I imagine it would work the same way.  I have a VB.NET program that I would like to do this with in addition to C++ addins.

  2. descapa says:

    basketcase39  – You can do the same with VB.Net, you would just need to create a COM addin with VB.Net and then register that with OneNote.  Most of it will be the same directions, I just don’t know how to program in VB.Net.  If you take my directions found here:

    You can see how to do it in C#, it should be fairly easy from that.

    If you get it working please shoot me a line so I can post it on my blog!

  3. After some lengthy discussions with the seller and his broker, I discovered that the seller had a first mortgage with a balance of about $125,000

  4. alexandre7g says:

    The term of ‘Add in’ doesn’t define a ‘plug in’,isn’t it?

  5. Hi Daniel, I’m wondering if the C++ approach to add-ins would make sense for this: I want/need to add a function for napkin math.  It has a nice set of functions already, but I want to be able to type in quad(1,-1,-1) and have it return the quadratic roots of the function x^2-x-1.  What do you think?  Could you point me in the right direction to getting this question answered?


  6. When I get navigation events from OneNote add-in, I get only a string ObjectId as a parameter. I want to take this event and re-create it later with NavigateTo. According to MSDN, NavigateTo takes one parameter, ObjectId. This should be ok, however the .h file you supply here says that NavigateTo takes 2 parameters, HierarchyId and ObjectId. This is inconsistent. Is there perhaps a newer .h file? I can’t find it anywhere. Why isn’t it posted online? We should be able to download the official .h file from somewhere other than your blog.

  7. Ulkesh says:

    It is giving this error.How to slove it,pls reply. incorrect <rpcndr.h> version. Use the header that matches with the MIDL compiler.

    Error executing cl.exe.

  8. sai says:

    Please provide the above mentioned sample code in C++