Pasting markup (HTML) text into a document programmatically

P

PromisedOyster

We have a C#/Word interop program that creates and populates word
documents. I want to extend this so that the word document can have
bold, underline, italic etc.

The text that we paste into our documents is fed from a database.
Therefore, what I want to have in the database is something like
'<b>Hello</b><u> World</u>' as opposed to simply 'Hello World'

When I try this, these just get treated literally
 
B

Bruce Maples

Well -- how are you inserting the text? Mailmerge? You're going to
have to write some code that parses what is coming out of the
database, then applies the formatting as the text goes into the Word
doc.

Your codes get treated literally because Word doesn't know what you
want to do -- treat them as HTML, or just typing?

It may be ugly, depending on how you do it -- you could parse
character by character, OR perhaps you could do a search-and-replace
once the text is in there.

Good luck.
 

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