OneNote 2016: How to: selected text in a page & subscribe to the onClick event

249 views Asked by At

I want to implement a COM OneNote Add-In (for OneNote Desktop) with the following functionality:

  • User selects some text and then clicks the FORMAT button exposed by the add-in: the add-in will format the selected text in some specific way (e.g. surround the text with "<<>>" and change its background and foreground color.
  • Later on when the user clicks on a text that was formatted as described above the add-in kicks in and copies the text in clipboard

I am new to COM add-ins, and I wasn't able to find a good API documentation. I've started with VanillaAddIn (https://github.com/OneNoteDev/VanillaAddIn) and now I need to add my functionality. I would really appreciate any help with the following:

  1. How to get the selected text from a page?
  2. How to subscribe to the OnClick event?
  3. Is there a good/decent OneNote API documentation? I found some links but I still hope there is a better one that I missed so far.
1

There are 1 answers

3
jayongg On BEST ANSWER
  1. To get selected text from a page, look at the GetPageContent API. You can see it used here: https://github.com/OneNoteDev/VanillaAddIn/blob/master/VanillaConsole/Program.cs

From the page content xml, you can find some elements that are "selected".

  1. OnClick event: There's no way to know when someone clicks on some text on the page, unfortunately.

  2. One site that can help with parsing the page content is the OneNote XSD. Here: https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/63/17/0336.OneNoteApplication_2013_xsd.txt