Home All Groups Group Topic Archive Search About

Copying formatted text from Word into Rtf

Author
26 Jan 2006 9:11 AM
Philip Galea
Hello,

I would like to know if there is another way to obtain the formatted text
(preferably in a Rtf format) from a Range object in the Word Object Model
WITHOUT using the clipboard from C#? I'm using the Office PIA's (and Office
2003).

Basically the background for the capability is we would like have an
"import" feature which can import Word documents, but dissect the document
into paragraphs using Word's powerful DOM.

The problem is we can only obtain the plain text from the Range Object but
if we wish to have the formatted text we need to use the clipboard which is
an annoyingly slow process, not to mention its frustrating for users as it
essentially locks them out from using the clipboard during the import. (This
is clearly not a good end user experience).

The alternatives we are considering using are:

- generating the Rtf ourselves using the RtfBox control and the information
we have in the selected Range (fonts, formatting etc).
- using the .XML property on the Range object.  The only thing putting me
off this is if the schema changes.

Aside: At the “Live!” event I heard that the next version (>2003) of Word
would be sporting a more open XML format.  How would this impact the XML
property of the Range object?

Many Thanks

AddThis Social Bookmark Button