Reputation: 307
I'm trying to create a new page in OneNote 2013 via C#.
try
{
onenoteApp.CreateNewPage(sectionId, out pageId, NewPageStyle.npsBlankPageWithTitle);
}
catch (System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine(ex.Message);
}
Every time the COMException occurs with the message:
"Exception of HRESULT: 0x8004200B".
The errorcode means the section is read-only (hrSectionReadOnly
).
I'm not able to get the section readable to add more pages or to update to content. I tried to change the security settings of the .one files but without success.
Does anyone know how to fix this problem?
Upvotes: 2
Views: 1540
Reputation: 55
I've had the same problem working with C# and OneNote. Everytime I was calling a "write"-method, meaning that I wanted to edit something in a OneNote-File, I got the Exception of HRESULT: 0x8004200B.
I was using the Microsoft OneNote 12.0 type Library as Reference. I tried to use the 14.0 type Library as well, but on every method the complier said something like
Error 1 'Microsoft.Office.Interop.OneNote.Application' does not contain a definition for 'GetHierarchy' and no extension method 'GetHierarchy' accepting a first argument of type ...
So the solution for me was using the OneNote 14.0 type Library AND set the Embed Interop Types to FALSE. You can find it by clicking on the OneNote Reference (when you already added it) down in the proberties.
Since then, everything worked fine!
Upvotes: 1