I have a OneNote notebook "template" that I copy into a new folder when I start a new project. I'm trying to write an application to update a couple hyperlinks on one of the pages in a section in the notebook.
using Microsoft.Office.Interop.OneNote; // ... Microsoft.Office.Interop.OneNote.Application oneApp = new Microsoft.Office.Interop.OneNote.Application(); oneApp.OpenHierarchy(filePath, string.Empty, out strID); oneApp.GetPageContent(strID, out pageXMLContent); // code to determind the ID of the page I want to update & update strID oneApp.GetPageContent(strID, out pageXMLContent); // code to replace hyperlink content here oneApp.UpdatePageContent(pageXMLContent);
I get a COMException - Exception from HRESULT: 0x8004200B on the UpdatePageContent line, which the error codes section of the developer reference says is 'The section is read-only'. How do I change the section to not be read-only?
In the first GetPageContent results there is a 'readOnly=true' property...I have tried updating the pageXMLContent to say 'readOnly=false' and set it with an UpdateHierarchy command, but it doesn't seem to change anything (GetPageContent returns the exact same thing afterwards). I've also try ensuring that read-only and archive options are not checked on the file properties of the OneNote notebook files and moving the notebook from a network location to the My Documents folder on my local drive to try to make sure it isn't a file access issue.
I've done a fair amount of Google searching and have skimmed through most of the OneNote Developer Reference material and haven't seen anything about this issue...any help would be appreciated.