RayMartinsHair

Hi,

I am doing some proof of concept work at the moment that requires me to be able to programtically copy text from a VS rich textbox in an active panel into the hosting MS word document.

I basically want to preserve any formatting of the text so that it displays the same in the RTF text box and in the word document.

If you use the .rtf property of the rtf text box the text is copied but the rtf formatting appears as text

ie

'{\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Microsoft Sans Serif;}}{\*\generator Riched20 5.50.99.2010;}\viewkind4\uc1\pard\ul\b\i\f0\fs24 hELLO\par\ulnone\b0\i0\f1\fs17\par'

when it should appear as hELLO

Can this be done If so can some one point me in the right direction.

I also have a requirement to be able to capure formatted text from Word (.doc not .rtf) and display it the a richtext text box.

Can this be also be done again a heads up in the right direction would be appreciated.

Thanks in advance.

Cheers
Adam



Re: Visual Studio Tools for Office Copying RTF into word and from word to a richtext box using c#

Cindy Meister

It is not possible to directly transfer the content of a RichText control into a Word document. Word requires a converter to display RTF as Word text, and its built-in converters only trigger on pasting from the Clipboard or inserting from an external file.

The same would hold true for transferring formatted text in Word to an RTF control: either save it in RTF format to a file and stream that into the control. OR copy to the clipboard and paste into the control.

Other than that, if we're discussing Word 2003, you could build a converter (transform) into your project that turns the RTF into WordProcessingML. It is possible to insert Word's native XML directly into a Word document.






Re: Visual Studio Tools for Office Copying RTF into word and from word to a richtext box using c#

Steve 5656565656

Does anyone know of a way to transform RTF to WordML and transform WordML to RTF   Is there a streamlined way to accomplish this



Re: Visual Studio Tools for Office Copying RTF into word and from word to a richtext box using c#

Cindy Meister

Hi Steve

Better to post a new question, with a link to any relevant, existing discussion. If you post to a message thread already marked as "Answered", there's a good chance no one will see it...

You're more likely to get a discussion on your question, with possible recommendations for (third-party) transforms in the newsgroup interface. Technically, the office.xml newsgroup would be appropriate, and you should try there. But as that gets relatively little traffic, asking in one of the general office.developer newsgroups (see "Please Read First" at the top of this forum) would be a good idea, as well.






Re: Visual Studio Tools for Office Copying RTF into word and from word to a richtext box using c#

Steve 5656565656

I have implemented Aspose.Word recently and it works well for me.

Steve