OneNote Interop API UpdatePageContent breaks Spell Checking

stemarcoh 11 Reputation points
C# with .NET Framework 4.8, OneNote 16.0.16924.20150 64-bit

Using the interop API, IApplication.UpdatePageContent(xml, lastModTime, XMLSchema.xs2013, true)

Given a page with an OE paragraph, where the user selects a run of text, not including the end of the text, and the text contains spelling errors before, within, and after the selection range.

When the proofing language is changed for the selected range, then the spelling errors after that range will no longer be highlighted as errors.

Here is an example text run, before modification, with a selection range. Notice the word "benoyd" is misspelled and would be highlighted by OneNote.

  <one:OE alignment="left" quickStyleIndex="1" selected="partial">
    <one:T><![CDATA[To ]]></one:T>
    <one:T selected="all"><![CDATA[infinity]]></one:T>
    <one:T><![CDATA[ and benoyd...]]></one:T>

And after modification to change the language of the selected range:

  <one:OE alignment="left" quickStyleIndex="1">
lang=en-US>To </span><span lang=yo>infinity</span><span lang=en-US> and benoyd...</span>]]></one:T>

But the word "benoyd" is no longer highlighted as misspelled. The user can manually iterate through the text by interactively clicking the Review/Spelling button, causing OneNote to highlight the misspellings.

Alternatively, if the user changes the proofing language of the selected range interactively using the Proofing Language panel, it results in exactly the same XML structure generated by OneNote natively, but OneNote retains the misspelling indicators.

Making exactly the same changes to the XML using the UpdatePageContent API should result in the same behavior as using the UI.

A family of Microsoft products that enable users to capture, organize, and reuse notes electronically.
178 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,699 questions
0 comments No comments
{count} votes