I am trying to imjport a word range into a rtb document and get a Dir not found exception.
Microsoft.Office.Interop.Word.Range oPage;
oPage = _WordDoc.Range(beginChar, endChar);
string sXML = oPage.WordOpenXML;
Telerik.WinControls.RichTextBox.Model.RadDocument document = null;
Telerik.WinControls.RichTextBox.FormatProviders.IDocumentFormatProvider docProvider = new Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.DocxFormatProvider();
byte[] byteArray = Encoding.ASCII.GetBytes(sXML);
document = docProvider.Import(byteArray); <== Exception thrown here
The sXML var can be put into a word doc and saved so I know the sXML data is not corrupt
ex.
Microsoft.Office.Interop.Word.Document oTempDoc = _WordApp.Documents.Add();
oTempDoc.Paragraphs[1].Range.InsertXML(sXML);
I also tried using a stream and got the same error
MemoryStream stream = new MemoryStream(byteArray);
document = docProvider.Import(stream);
So far the only thing that seems to work is to save the word fragment to a file and the turn around and import the file, but that is a lot of hoop jumping to get the word fragment into the rtb.
Any suggestions?
Mike
Microsoft.Office.Interop.Word.Range oPage;
oPage = _WordDoc.Range(beginChar, endChar);
string sXML = oPage.WordOpenXML;
Telerik.WinControls.RichTextBox.Model.RadDocument document = null;
Telerik.WinControls.RichTextBox.FormatProviders.IDocumentFormatProvider docProvider = new Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.DocxFormatProvider();
byte[] byteArray = Encoding.ASCII.GetBytes(sXML);
document = docProvider.Import(byteArray); <== Exception thrown here
The sXML var can be put into a word doc and saved so I know the sXML data is not corrupt
ex.
Microsoft.Office.Interop.Word.Document oTempDoc = _WordApp.Documents.Add();
oTempDoc.Paragraphs[1].Range.InsertXML(sXML);
I also tried using a stream and got the same error
MemoryStream stream = new MemoryStream(byteArray);
document = docProvider.Import(stream);
So far the only thing that seems to work is to save the word fragment to a file and the turn around and import the file, but that is a lot of hoop jumping to get the word fragment into the rtb.
Any suggestions?
Mike