Word document with XML - content copy causes error.

P

Petrowi

Hi.

The program I'm working on saves the current Word document in WordML format,
modifies the saved data (as an XML document), saves the modified data in temp
XML file, opens that file in Word and copies the contents form the temp
document over the original one:

(Original Doc) -> (SaveAs WordML) -> (Modify WordML) -> (Save Temp WordML)
-> (Open Temp WordML in Word) -> (Copy Temp contents over Original contents).

I use this process to speed up otherwise slow operations in Word.

The documents involved have custom Schema and XML markup themselves.

The problem comes when I do this (C#):

wdDocument.Content.FormattedText = tempWdDoc.Content.FormattedText;

The line above throws an exception:

System.Runtime.InteropServices.COMException (0x800A17EA): This action is
not valid outside of a block-level XML element.
at Microsoft.Office.Interop.Word.Range.set_FormattedText(Range prop)

It seems only some machines have this problem.

Does anyone have a clue what this message is?

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top