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

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

  • Comments 9

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!

Leave a Comment
  • Please add 4 and 3 and type the answer here:
  • Post
  • PingBack from http://www.onenotepowertoys.com/2007/02/17/developers-links-to-dan-escapas-posts/

  • 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.

  • 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:

    http://blogs.msdn.com/descapa/archive/2006/08/31/734298.aspx

    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!

  • 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

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

  • 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!

  • 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.

  • 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.

  • Please provide the above mentioned sample code in C++

Page 1 of 1 (9 items)