locked
Select several objects in OneNote programmatically RRS feed

  • Question

  • Hi all!
    Is there any way to select several objects in OneNote programmatically?
    And it would be great to accomplish this without updating the page (because the page is in read-only mode).
    Can I, for example, via Win32 API select several objects in current OneNote window? (each object is a table cell with its own objectID)
    Thanks.
    • Moved by Cindy Meister MVP Monday, August 20, 2012 12:04 PM not using VSTO technology (From:Visual Studio Tools for Office)
    Monday, August 20, 2012 7:28 AM

All replies

  • Hi Alexander,

    Thank you for posting in the MSDN Forum.

    I'll involve some experts who are more familiar with your issue. This may take some time.

    Thank you for your patient and understanding.

    Best regards,
    Quist

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, August 22, 2012 5:15 AM
  • The OneNote file format is xml based so you can parse through the page content and access the objects individually if you want.  Do you need to have the objects literally selected or do you just need their contents?

    Here are a few reference articles that might be helpful. 

    http://msdn.microsoft.com/en-us/library/aa203882(v=office.11)
    http://msdn.microsoft.com/en-us/library/ms788684(office.12)
    http://msdn.microsoft.com/en-US/office/aa905452

    Brandon

    • Marked as answer by Quist Zhang Monday, September 3, 2012 1:48 AM
    • Unmarked as answer by Alexander.Demko Monday, September 3, 2012 5:44 AM
    Wednesday, August 29, 2012 4:20 PM
  • In my case - the section is in read only mode (the section file marked with attribute "read only"). So I can not update the page xml.

    I need to raise mouse event in the area of object (table cell), for example. Or something else. For this I need to get the object coordinates.

    For example if I create an OneNote link from one page to another page object - the link will be looks like "onenote://J:/....". We can find the "onenote:" protocol handler in regedit. The handler is "C:\Program Files\Microsoft Office 15\Root\Office15\ONENOTE.EXE" /hyperlink "%1".

    So If I run onenote.exe with parameter "/hyperlink [the link]" - OneNote will open the page and the object will be selected!

    So I want something like this but for several objects. For example to call method of OneNote.exe or DLL library to select page objects.

    Thanks.

    Wednesday, August 29, 2012 4:36 PM
  • You can still get the page content even if the file is marked Read-Only without updating anything.  You are just pulling the xml contents of the page. 

    If you want object coordinates, then you should be able to create a COM add-in and hook into the events to get that information.  I don't think the object model has a selection event though, so you might have to use Win32 API's or MSAA/UIAutomation.

    Brandon

    • Marked as answer by Quist Zhang Monday, September 3, 2012 1:48 AM
    • Unmarked as answer by Alexander.Demko Monday, September 3, 2012 5:44 AM
    Wednesday, August 29, 2012 5:09 PM
  • Yes.  Win32 API's or MSAA/UIAutomation - that is what I need. But what methods should I use? 

    Can you provide more information about it?

    Wednesday, August 29, 2012 5:14 PM
  • I don't know of a specific method/event that will do it.  It would likely have to be a combination of logic to get multiple items selected on a page.  Multiple selection is tricky in OneNote.  For example, you couldn't select the first and last word on a line individually (unless each item you are selecting is in a different note container).  You can select the first word of line one and the first word of line two. 

    You could try opening a support case and one of the developer support teams might be able to provide some guidance.  The link below can help get you started with the various paid support options if you so choose.  

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Otherwise you can search for some of the previously created OneNote PowerToys/Addins.  Sometimes they include the source code and you might be able to get some ideas from that.  Sorry I don't have a ready made sample or command line parameter that does it directly like /hyperlink. 

    Brandon

    • Marked as answer by Quist Zhang Monday, September 3, 2012 1:48 AM
    • Unmarked as answer by Alexander.Demko Monday, September 3, 2012 5:43 AM
    Wednesday, August 29, 2012 8:23 PM