Compartir a través de


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:

    #include
    "OneNote12.h"

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

        CoInitialize(NULL);

        IApplication* piOneNote;

     

        CoCreateInstance(__uuidof(Application), NULL,

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

     

        if(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!

Downloads:

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

Comments

  • Anonymous
    February 17, 2007
    PingBack from http://www.onenotepowertoys.com/2007/02/17/developers-links-to-dan-escapas-posts/

  • Anonymous
    March 15, 2007
    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.

  • Anonymous
    March 16, 2007
    The comment has been removed

  • Anonymous
    March 24, 2007
    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

  • Anonymous
    April 20, 2007
    The term of 'Add in' doesn't define a 'plug in',isn't it?

  • Anonymous
    May 17, 2009
    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? Thanks!

  • Anonymous
    January 25, 2010
    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.

  • Anonymous
    April 04, 2011
    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.

  • Anonymous
    June 02, 2011
    Please provide the above mentioned sample code in C++