locked
Microsoft.Office.Interop.OneNote CloseNotebook Method is no work RRS feed

  • Question

  • Hi All,

    I've development console app for get Microsoft OneNote content.

    using Microsoft.Office.Interop.OneNote 14.0.0.0

    my computer is office 2013

    I can get content but when i want to close the section it'll error 0x80042015, and i find this error code it mean is 

    hrNotebookDoesNotExist 0x80042015 The notebook does not exist.

    my sample code at below;

    Microsoft.Office.Interop.OneNote.Application onApplication = new Microsoft.Office.Interop.OneNote.Application();

    onApplication.OpenHierarchy(targetURL,System.String.Empty, out strID,Microsoft.Office.Interop.OneNote.CreateFileType.cftSection);

    onApplication.GetPageContent(strID, out xmlfromet, Microsoft.Office.Interop.OneNote.PageInfo.piBasic);

    XmlDocument infodoc1 = new XmlDocument();

    infodoc1.LoadXml(xmlfromet);

    XmlNodeList direclty1 = infodoc1.GetElementsByTagName("one:Section");

    foreach (XmlNode itemss in direclty1)
    {

    //get content....

    }

    onApplication.CloseNotebook(strID, true);

    how to fix this error it can't be close issue?

    Friday, April 29, 2016 6:28 AM

Answers

  • >>>I can get content but when i want to close the section it'll error 0x80042015, and i find this error code it mean is 

    hrNotebookDoesNotExist 0x80042015 The notebook does not exist.<<<

    According to your description, as far as I know that we cannot close a section in OneNote 2007. Based on my testing, I cannot close a section in OneNote 2013.

    To work around this issue, use either of the following methods:
    Move the section to a new notebook. Then, close the new notebook.
    Save the section to another location. Then, open the file manually. 

    For more information, click here to refer about You cannot close a section in OneNote 2007

    In addition you could refer about Programmatically Opening and Closing a Notebook in OneNote 2010

    and Application Interface (OneNote 2010)
    Monday, May 2, 2016 5:41 AM