I am trying to figure out how to add a notebook in OneNote 2010. I can not find any code samples that shows how to use the UpdateHiearchy API to add a new notebook. I am trying to do this from a VB6 application. I am new to using xml from VB. the code is as follows:
Private Function GetFirstOneNoteNotebookNodes(oneNote As OneNote14.Application) As MSXML2.IXMLDOMNodeList
' Get the XML that represents the OneNote notebooks available.
Dim notebookXml As String
' OneNote fills notebookXml with an XML document providing information
' about what OneNote notebooks are available.
' You want all the data and thus are providing an empty string
' for the bstrStartNodeID parameter.
oneNote.GetHierarchy "", hsNotebooks, notebookXml, xs2010
' Use the MSXML Library to parse the XML.
Dim doc As MSXML2.DOMDocument
Set doc = New MSXML2.DOMDocument
Dim elem As MSXML2.IXMLDOMElement
If doc.loadXML(notebookXml) Then
' Here is search for a notebook that i know is not there. mvarpAssignment.pClient.Name is a program variable that contains a text name.
Set GetFirstOneNoteNotebookNodes = doc.documentElement.selectNodes("//one:Notebook[@name='" & mvarpAssignment.pClient.Name & "']")
' I test the length for zero to see if anything was returned:
If GetFirstOneNoteNotebookNodes.Length = 0 Then
' I want to create a notebook, so i beleive i need to add an element to the xml returned from the GetHiearchy API:
Set elem = doc.createElement("ROC")
doc.documentElement.appendChild elem
'I print out the xml and i can see the element added at the end of the xml document.
Debug.Print doc.XML
' the next step would be to call the UpdateHiearchy API but i am at a loss as to whch object i pass into the API. Everything i try fails. I obviously dont understand this enough but i can't find any code samples or any text that describes how to add a notebook. any help or any links to infomration would be greatly appreciated!