Writing OneNote toolbar add-in
Reference: Ccreating Toolbar Buttons in OneNote 2007,
We allow you to create a toolbar button which is either an icon or text that will sit on one of the OneNote command bars. They can appear on the standard toolbar at the end of the menus or on any other toolbar. When the user clicks on the button we will CoCreate your code (since you implement an interface we make available) and we send you the current page that was sent. You can see that it looks like this:
Download sample code from OneNote Web Exporter http://www.codeplex.com/ONWebber. The solution contains
- a C# console application project called “cwebber”.
- a C# class library project called “Webber”.
- a setup project called “Webber Setup”.
Webber Setup will install cwebber and create its Start Menu shortcut and register Webber as a OneNote add-in. To debug Webber:
- Build Webber Setup and run the .msi to setup the add in
- At the beginning of the OnClick event of the add-in (found in Program.cs), put a MessageBox in order to suspend the process when the event has fired, given us enough time to attach the debugger.
- In OneNote, click on the add-in icon. The message box will be displayed.
- With the MessageBox displayed, go to visual studio, open the Webber solution, choose Debug->Attach to Process and select dllhost.exe (aka COM surrogate), which is the process responsible for handling the add-in’s DLL
- Breakpoints will now be hit.
Tip: After you’ve installed the .msi for the OneNote add-in, on some subsequent changes to the code, you don’t have to uninstall and re-install the msi. Just quit OneNote, ensure that the project properties for webber have been set to “Register for COM interop”, build it, and the changes will be reflected.