Unable to create a page

Feb 3, 2011 at 10:08 AM
Edited Feb 3, 2011 at 11:08 AM

I am trying to create a page for a section using the ONOM and I am getting the following error:

 

Microsoft.Office.OneNote.OneNoteException was unhandled
  Message=Unable to modify read-only section.
  Source=OneNoteCore
  ErrorCode=-2147213301
  StackTrace:
       at Microsoft.Office.OneNote.OneNoteApplication.VerifySuccess(Int32 errorCode) in D:\POCs\onomVS2008SP1\OneNoteCore\OneNoteApplication.cs:line 241
       at Microsoft.Office.OneNote.OneNoteApplication.CreateNewPage(OneNoteObjectId sectionId, NewPageStyle newPageStyle) in D:\POCs\onomVS2008SP1\OneNoteCore\OneNoteApplication.cs:line 79
       at Microsoft.Office.OneNote.OneNoteApplication.CreateNewPage(OneNoteObjectId sectionId) in D:\POCs\onomVS2008SP1\OneNoteCore\OneNoteApplication.cs:line 86
       at Microsoft.Office.OneNote.OneNoteSection.CreatePage() in D:\POCs\onomVS2008SP1\OneNoteFramework\TypesHierarchy\OneNoteSection.cs:line 31
       ....

 

This is the piece of code that I used:

//Notebook Open

      string path = @"D:\OneNotePocs";

     OneNoteNotebook notebook = OneNoteHierarchy.Current.OpenNotebook(path);

     // Section open

     OneNoteSection section = notebook.OpenSection("SR Number");    

     OneNotePage pageForSR = null;

     if (section.Pages != null)

     {

       foreach (OneNotePage page in section.Pages)

       {

         if (page.Name == "123")

         {

           pageForSR = page;

           break;

         }

       }

     }

     if (pageForSR == null)

     {              

 

       section.CreatePage();

 

 Any help would be really immense here!!

 I am using VS2010 and trying to integrate an app with ON 2010

Cheers, AC