HTML Tags in RichTextContentControl

C

C.N.Siva

I am dynamically creating a richtextcontentcontrol using VSTO (Word 2007).
The text that is set to the control will be something like
“<div><b>Data</b></div>â€. I expect the richtextcontentcontrol to detect the
HTML tags and display the text with HTML formatting, but that is not the
case. It simply displays the text with HTML tags.

Here is the source code:
Microsoft.Office.Tools.Word.RichTextContentControl customControl =
Globals.ThisDocument.Controls.AddRichTextContentControl(contentRange, name);
customControl.Text = "<div><b>Data</b></div>";
Please let me know if I am doing something wrong here and if there is any
alternate solution.

This is an urgent requirement. Please help me out.

Thanks in advance
C.N.Siva
 
C

Cindy M.

Hi =?Utf-8?B?Qy5OLlNpdmE=?=,
I am dynamically creating a richtextcontentcontrol using VSTO (Word 2007).
The text that is set to the control will be something like
“<div><b>Data</b></div>â€. I expect the richtextcontentcontrol to detect the
HTML tags and display the text with HTML formatting, but that is not the
case. It simply displays the text with HTML tags.

Here is the source code:
Microsoft.Office.Tools.Word.RichTextContentControl customControl =
Globals.ThisDocument.Controls.AddRichTextContentControl(contentRange, name);
customControl.Text = "<div><b>Data</b></div>";
Please let me know if I am doing something wrong here and if there is any
alternate solution.

This is an urgent requirement. Please help me out.
RichText content controls are part of Word. They only "understand" Word's file
native format. HTML is not Word's native file format. Word requires a converter to
"understand" HTML. The Word HTML converter only kicks in when inserting the HTML
from a file or pasting it from the Clipboard.

The common workaround for something like this is to place your HTML on the
Clipboard then use the Range.Paste method of the Word object model to put it into
the Range (in this case, the ContentControlObject.Range).

If you search the VSTO forum on MSDN you should find a number of discussions about
how to put HTML on the Clipboard so the Word can retrieve it:
http://social.msdn.microsoft.com/Forums/en-US/vsto/threads/#page:1

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 

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