Caution: addictive material! Handle with care.


It was more difficult than we expected. Our fingers are exhausted, and we won’t even talk about the truly frightening quantities of Mt. Dew that were consumed. The end result: a shiny pile of ones and zeros we think you’ll want to meet.


Previously I hinted that Omar, David and myself have been collaborating on a nicely abstracted managed assembly that provides an object model for importing data into OneNote. But as of today, it lives!


So what does it do, you ask? Enough talk:

using Microsoft.Office.OneNote; 
namespace Example
{
   class TrivialImport
   {
      public static void Main()
      {
         // Create a new page in the section “General”, with the
         // title “Import Example”.

         Page p = new Page(“General.one”, “Import Example”);

         // Create a new Outline, and add some content to it:
         OutlineObject outline = new OutlineObject();
         outline.AddContent(new HtmlContent(“Hello <i>world</i>!”));


         // Add the outline to our page:

         p.AddObject(outline);


         // Commit the changes to OneNote, and set the actively viewed page:

         p.Commit();
        p.NavigateTo();
      }
   }
}

Try it out for yourself: the assembly, source code, documentation, and class diagrams are all available for download here.


(Note that this is a work in progress, and as a result you may encounter the occasional bug or two. So if it eats your homework, erases all of your Tivo’d episodes of Friends, or breaks up with your girlfriend — you have been warned. Of course, if this does occur, let me know.)


Go wild; but be careful: once you start importing, it’s hard to stop.


[3/22/06: Updated URLs to point to new site.]

Comments (57)

  1. WWs Blog says:

    OneNote managed API

  2. WWs Blog says:

    OneNote managed API!

  3. V says:

    Hmmmm… I tried that sample, and it crashes with:

    Unhandled Exception: Microsoft.Office.OneNote.ImportException: OneNote is not installed on this machine!

    at Microsoft.Office.OneNote.SimpleImporter..ctor()

    at Microsoft.Office.OneNote.Page.Commit()

    at Example.TrivialImport.Main()

    What am I missing?

  4. Do you have the OneNote SP1 Preview installed? (If not, you can download it from: http://www.microsoft.com/office/onenote/sp1/) DataImport is a new feature of the SP1 release.

  5. Jeff Borlik says:

    Nice job, Donovan. It certainly makes developing for OneNote much easier. Thanks!

    Question, though: What kinds of HTML tags are valid for import into OneNote? (I suppose that this would apply to the COM and command-line as well.) Is that documented somewhere? Bold and italic work, obviously, but support for some other tags seems to be spotty.

  6. Unfortunately, the set of supported html tags isn’t well documented anywhere officially. (This is something that I can try to remedy as we prepare to ship.) I should mention that for those experimenting, you may notice that the html support is exactly the same as pasted html content from the clipboard. They’re actually one and the same, so if it works when you copy and paste from IE, it should also work via an Import.

    That being said, one of the goals of the C# classes posted here is to work around some of the nuances (which is the polite way of saying bugs) of the underlying COM interface. You’ll notice that we already massage HTML input in the HtmlContent class quite a bit. Are there specific tags that aren’t working as you’d expect?

  7. Okay, I confess, I’m not a programmer. If I register the DLL, will that do the trick or does the code have to be compiled into some sort of executable?

  8. If you add it as a reference to your Visual Studio project, that should do the trick.

    Hope this helps,

    Donovan

  9. robrohr.org says:

    Eye of OneNote Managed API, dash of providers, seive through Sharepoint event list schema, and what do you have?

    Ummm…

  10. robrohr.org says:

    Eye of OneNote Managed API, dash of providers, seive through Sharepoint event list schema, and what do you have?

    Ummm…

  11. robrohr.org says:

    Eye of OneNote Managed API, dash of providers, seive through Sharepoint event list schema, and what do you have?

    Ummm…

  12. robrohr.org says:

    Last year at TechEd, I had the sweetest setup. My (at the time) new Gateway M275 TabletPC stuffed with every beta available (XP SP2 beta, Office 2003 beta, OneNote SP1 beta, InfoPath beta, etc.) was begging to be the envy of all conference attendees…

  13. Derek says:

    I really enjoyed the OneNote plugin to Outlook. I used both the Outlook and the IE plugin quite a bit. As of resent, in the last month or so, my OneNote icon in Outlook has disappeared. I have reinstalled, checked the .NET programming option for Outlook, etc.

    Do you have any ideas what I need to do to resolve this problem?

    Thanks,

    Derek

  14. Ray says:

    I’m a new OneNote user, and so far I love it!  I have a couple of questions/comments:

    – can it run from a USB drive (i.e. without needing to be installed on connected PC?)  It would be great for using at class for notes, then taking home.

    – what type of encription is used for the password protection?

    – can the new API be used to copy/paste from some other application?  And allow the other application to do the rendering of the inserted piece?

  15. College Loan says:

    Very good details and new. keep it posted.

  16. Last year the OneNote marketing team started a contest to&amp;nbsp; see how developers and enthusiasts used…

  17. robrohr.org says:

    Last year at TechEd, I had the sweetest setup.  My (at the time) new Gateway M275 TabletPC stuffed with every beta available (XP SP2 beta, Office 2003 beta, OneNote SP1 beta, InfoPath beta, etc.) was begging to be the envy of all conference attendees..

  18. This library is an easy and fun way to integrate OneNote with .NET apps. We&amp;#39;ve used it for our freeware

  19. Nice Jobs says:

    My name is Donovan Lange.  I’m a Software Design Engineer on Microsoft Office OneNote.

    I do not agree. Go to http://www.auditjobs.info

  20. My name is Donovan Lange.  I’m a Software Design Engineer on Microsoft Office OneNote.

    I do not agree. Go to http://www.autosjob.info/filiation_United%20Kingdom/hinny_England/unsportsmanlike_Torquay_1.html

  21. My name is Donovan Lange.  I’m a Software Design Engineer on Microsoft Office OneNote.

    I do not agree. Go to http://www.dojobs.info/vena_Netherlands/regulation_Holland/acropolis_Amsterdam_1.html

  22. Holly says:

    I’m seeking a software that can add the context in clipboard to onenote by using hotkey,does it have be done by anyone?or i have to try to do it myself.

  23. Look who’s here!

    Be seeing you.,Look who’s here!

    Be seeing you.,Look who’s here!

    Be seeing you.,Look who’s here!

    Be seeing you.

  24. How are you doing on?

    Bye.,How are you doing on?

    Bye.,How are you doing on?

    Bye.,How are you doing on?

    Bye.

  25. RSSBandit Plugin – RSS2OneNote

  26. .Net World says:

    Woohoo!, I love using Onfolio but I&#39;m also starting to love using OneNote too (only wish I had a

  27. sacchit.thakur@brainvisa.com says:

    Error: Attempting to import invalid XML!

    The error is coming while running the code on this page.

  28. sacchit.thakur@brainvisa.com says:

    I missed this line below

    [3/22/06: Updated URLs to point to new site.] point here http://lange.officeisp.net/DataImport/

  29. Interested Developer says:

    Does this assembly work with OneNote 2010?  Also, I cannot get the assembly zip file download to work.  It appears that lange.officeisp.net isn't available.