Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to publish OneNote document as PDF programmatically
    primarykey
    data
    text
    <p>I am attempting to convert a Microsoft OneNote document to a PDF file:</p> <pre><code> Microsoft.Office.Interop.OneNote.Application oneNote; oneNote = new Microsoft.Office.Interop.OneNote.Application(); string noteBookXML; oneNote.GetHierarchy(null, HierarchyScope.hsNotebooks, out noteBookXML); XDocument doc = XDocument.Parse(noteBookXML); XNamespace ns = doc.Root.Name.Namespace; foreach (var noteBookNode in from node in doc.Descendants(ns + "Notebook") select node) { string id = noteBookNode.Attribute("ID").Value; string path = "C:\\convert.pdf"; if (File.Exists(path)) File.Delete(path); try { oneNote.Publish(id, path, PublishFormat.pfPDF, ""); } catch(Exception ex) { Console.WriteLine(ex.Message); } } </code></pre> <p>With the above code I am currently getting to the publish call, stepping over it causes Microsoft OneNote to stop working (generic windows "X has stopped working please wait") followed by this exception:</p> <pre><code>{System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed. (Exception from HRESULT: 0x800706BE) at Microsoft.Office.Interop.OneNote.ApplicationClass.Publish(String bstrHierarchyID, String bstrTargetFilePath, PublishFormat pfPublishFormat, String bstrCLSIDofExporter) at Conversion.OneNoteConverter.run() in G:\Code\OneNoteConversion\Conversion\OneNoteConverter.cs:line 34} </code></pre> <p>Has anyone been able to get this working? Am I doing something obviously wrong?</p> <p>Thanks in advance.</p> <p>Resources I've been trying to follow:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms788684.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms788684.aspx</a></p> <p><a href="http://social.technet.microsoft.com/Forums/en/office2010/thread/900dd92b-6e5c-40e5-86ec-f18c1a1fc050" rel="nofollow">http://social.technet.microsoft.com/Forums/en/office2010/thread/900dd92b-6e5c-40e5-86ec-f18c1a1fc050</a></p> <p><a href="http://www.technologyquestions.com/community/threads/api-onenote-2007-publish.117776/" rel="nofollow">http://www.technologyquestions.com/community/threads/api-onenote-2007-publish.117776/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload