Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:30:55+00:00 2026-06-05T23:30:55+00:00

I am attempting to convert a Microsoft OneNote document to a PDF file: Microsoft.Office.Interop.OneNote.Application

  • 0

I am attempting to convert a Microsoft OneNote document to a PDF file:

        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);
            }
        }

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:

{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}

Has anyone been able to get this working? Am I doing something obviously wrong?

Thanks in advance.

Resources I’ve been trying to follow:

http://msdn.microsoft.com/en-us/library/ms788684.aspx

http://social.technet.microsoft.com/Forums/en/office2010/thread/900dd92b-6e5c-40e5-86ec-f18c1a1fc050

http://www.technologyquestions.com/community/threads/api-onenote-2007-publish.117776/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:30:57+00:00Added an answer on June 5, 2026 at 11:30 pm

    It turns out when using the .publish call you need OneNote open in order for it to work (or you will get an exception).

    Opening OneNote before the call allowed it to perform and convert the document from .one to .pdf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to convert a string to a TStream. My code below gives me
In my service layer for my MVC application I am attempting to convert the
I'm attempting to take an NSImage and convert it to a string which I
I am attempting to convert a float into a string. I have a string
I'm attempting to convert a PDF into a single image using GhostScript. Only the
I have an application I am attempting to convert from a flex 3 air
I'm fairly new to mod_rewrite and I am attempting to convert a URL from
I am attempting convert this string 2012-02-05T00:00:00+00:00 into a more attractive, nicely formatted string
I'm attempting to convert a Python application I coded using the cmd module into
I'm attempting to convert a PDF to a JPEG using ImageMagick. The PDF: baby_aRCWTU.pdf

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.