vb.net - Programmatically adding/displaying/inserting images to OneNote 2013 -


i'm having trouble adding image page in onenote 2013. can create sections, notebooks , pages content, i'm having trouble adding image page.

i call updatepagecontent , pass in xml invalid xml message (hresult 0x80042001) back. assistance appreciated. here complete code use create xml i'm trying update page with:

sub createnewpage(byval pagename string)     dim onenote microsoft.office.interop.onenote.application     onenote = new microsoft.office.interop.onenote.application      ' of notebook nodes.      dim nodes msxml2.ixmldomnodelist     nodes = getfirstonenotenotebooknodes(onenote)     if not nodes nothing         ' first onenote notebook in xml document.          dim node msxml2.ixmldomnode         node = nodes(0)         dim notebookname string = ""         notebookname = node.attributes.getnameditem("name").text          ' id notebook code can retrieve          ' list of sections.          dim notebookid string         notebookid = node.attributes.getnameditem("id").text          ' load xml sections notebook requested.          dim sectionsxml string = ""         onenote.gethierarchy(notebookid, microsoft.office.interop.onenote.hierarchyscope.hssections, sectionsxml)          dim secdoc msxml2.domdocument         secdoc = new msxml2.domdocument          if secdoc.loadxml(sectionsxml)             ' select section nodes              dim secnodes msxml2.ixmldomnodelist             secnodes = secdoc.documentelement.selectnodes("//one:section[@name='balaji1']")              if not secnodes nothing                 ' first section.                  dim secnode msxml2.ixmldomnode                 secnode = secnodes(0)                  dim sectionname string = ""                 sectionname = secnode.attributes.getnameditem("name").text                 dim sectionid string                 sectionid = secnode.attributes.getnameditem("id").text                  dim doc msxml2.domdocument                 doc = new msxml2.domdocument                  'onenote.gethierarchy()                 dim sectionxml string = ""                 dim newpageid string = ""                 sectionxml = ""                 onenote.gethierarchy("", microsoft.office.interop.onenote.hierarchyscope.hspages, sectionxml)                 newpageid = getpageidbypagename(pagename, sectionxml)                  ' create new blank page in first section                  ' using default format.                  if len(newpageid) = 0                     onenote.createnewpage(sectionid, newpageid, microsoft.office.interop.onenote.newpagestyle.npsdefault)                 end if                 ' contents of page.                  dim outxml string = ""                 onenote.getpagecontent(newpageid, outxml, microsoft.office.interop.onenote.pageinfo.piall)                   ' load page's xml msxml2.domdocument object.                  if doc.loadxml(outxml)                     ' page node.                      dim pagenode msxml2.ixmldomnode                     pagenode = doc.selectsinglenode("//one:page")                      ' find title element.                      dim titlenode msxml2.ixmldomnode                     titlenode = doc.selectsinglenode("//one:page/one:title/one:oe/one:t")                      ' cdatasection onenote store's title's text.                      dim cdatachild msxml2.ixmldomnode                     cdatachild = titlenode.selectsinglenode("text()")                      'change title change pagename                     ' change title in local xml copy.                      cdatachild.text = pagename                     ' write update onenote.                      onenote.updatepagecontent(doc.xml)                      dim newelement msxml2.ixmldomelement                     dim newnode msxml2.ixmldomnode                      ' create outline node.                      newelement = doc.createelement("one:outline")                     newnode = pagenode.appendchild(newelement)                     ' create oechildren.                      newelement = doc.createelement("one:oechildren")                     newnode = newnode.appendchild(newelement)                     ' create oe.                      newelement = doc.createelement("one:oe")                     newnode = newnode.appendchild(newelement)                     ' create te.                      newelement = doc.createelement("one:t")                     newnode = newnode.appendchild(newelement)                      newelement = doc.createelement("one:image")                     newnode = newnode.appendchild(newelement)                      ' add text page's content.                      dim cd msxml2.ixmldomcdatasection                     cd = doc.createcdatasection("your text here")                      newnode.appendchild(cd)                      ' update onenote new content.                      onenote.updatepagecontent(doc.xml)                      ' print out information update.                      msgbox("a new page created in section '" & sectionname & "' in notebook '" & notebookname & "'.")                      debug.print(doc.xml)                 end if             else                 msgbox("onenote 2010 section nodes not found.")             end if         else             msgbox("onenote 2010 section xml data failed load.")         end if     else         msgbox("onenote 2010 xml data failed load.")     end if end sub 


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -