Ticket T838596
Visible to All Users

Append RichText Editor text to Microsoft.Office.Interop.Word

created 5 years ago

HI,

I have rich text editor in my application. Now when user enters any text in this, it get saved to database in following format

{\rtf1\deff0{\fonttbl{\f0 Calibri;}{\f1 Tahoma;}}{\colortbl ;\red0\green0\blue255 ;}{\\defchp \fs22}{\stylesheet {\ql\fs22 Normal;}{\\cs1\f1\fs20 Default Paragraph Font;}{\\cs2\sbasedon1\f1\fs20 Line Number;}{\\cs3\ul\fs22\cf1 Hyperlink;}{\\ts4\tsrowd\fs22\ql\tscellpaddfl3\tscellpaddl108\tscellpaddfb3\tscellpaddfr3\tscellpaddr108\tscellpaddft3\tsvertalt\cltxlrtb Normal Table;}{\\ts5\tsrowd\sbasedon4\fs22\ql\trbrdrt\brdrs\brdrw10\trbrdrl\brdrs\brdrw10\trbrdrb\brdrs\brdrw10\trbrdrr\brdrs\brdrw10\trbrdrh\brdrs\brdrw10\trbrdrv\brdrs\brdrw10\tscellpaddfl3\tscellpaddl108\tscellpaddfr3\tscellpaddr108\tsvertalt\cltxlrtb Table Simple 1;}}{\*\listoverridetable}\nouicompat\splytwnine\htmautsp\sectd\pard\plain\ql{\lang16393\langfe16393\f1\fs20\cf0 Test This}\f1\fs20\par}

Now when I try to append this text in word file using Microsoft.Office.Interop.Word like shown below

using Word = Microsoft.Office.Interop.Word;

Object index;
Word.Bookmark bookmark;

index = "WorkDescriptionDetail";
bookmark = objBill.Bookmarks.get_Item(ref index);
bookmark.Range.Text = r["WorkDescriptionDetail"].ToString();

This gets appended without any formatting. I have attached a screenshot of word file.

Hope you can help me. Thanks in advance.

Answers approved by DevExpress Support

created 5 years ago

Hi,

Please review the following webpages:
Inserting RTF content in existing text range in Word using Interop assemblies c#
How to insert text from RTF to Word Document in c#

Note that this question does not relate to our components, and it is better to ask Interop-related questions on specialized forums (Microsoft, StackOverflow, etc.).

In addition, would you please clarify why you need to use Interop methods? You can use our Word Processing Document API to insert RTF content to existing documents.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.