Rendering HTML tags in the WORD DOC (when dynamically loaded from SQL)

C

Chris Richardson

This is a question regarding how to render HTML tags in
the WORD DOC (when dynamically loaded from SQL).

I received a response from Doug Robbins - Word MVP. But I
have another question. Please read below. If anyone can
help I'd really appreciate it

Are you saying that for everything, the HTML Tables,
Horizontal Lines, Bullet and Number List, that I would
have to loop through and convert using the approach
mentioned below? Wow!

I was hoping for something simpler. I'm afraid that I
will not catch all of the HTML tags that are possible to
come through. Also, I wonder if the original look/fill
will be regained.

I read in a seperate post about someone using some code
like:

wrdApp.Documents.Open FileName:="C:\Docs\skeletal.doc",
Format:=wdOpenFormatHTML

I'm not sure what the "FormatHTML" does. Can you
elaborate on this please? Otherwise, can you advise on
any other alternative to making WORD render HTML (the way
that the IE Browser does).

Thanks in advance for taking the time to respond.
-----Original Message-----
Hi Chris,

The following code in a macro would delete the tags and apply bold
formatting to the text between the tags:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="\<(STRONG\>)(*)\</ \1",
MatchWildcards:=True, ReplaceWith:="\2", Wrap:=wdFindContinue,
Forward:=True) = True
Selection.Range.Font.Bold = True
Loop
End With

See the article "Finding and replacing characters using wildcards" at:

http://www.mvps.org/word/FAQs/General/UsingWildcards.htm

for and explanation of what the FindText string means.

You will need a similar routine to apply whatever other formatting is
required by other tags.
--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
"Chris Richardson"


.
..
 
C

Cindy Meister -WordMVP-

Hi Chris,
an you advise on
any other alternative to making WORD render HTML (the way
that the IE Browser does).
Dump the data coming from SQL Server (or whereever) with the
HTML tags into a plain text file, save it to disk with a
*.htm extension, then use Word's Open method (or InsertFile
method) on that to bring it into Word. That will bring
Word's HTML converter into play, rendering the HTML into
native Word binary file formatting.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan
24 2003)
http://www.mvps.org/word

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