Need a VBA method to convert a selection in a Word doc from HTML to Word format

J

John Socolofsky

I would like to find a VBA method that can take a
selection within a Word file as input and convert whatever
it finds within the selection from HTML to Word format and
paste it back into the Word file in place of the HTML.

What I am trying to do is take a Word file that contains
text, bulleted lists, and images, along with straight HTML
bounded by tags. I want to parse the Word file and when I
hit a starting bounding tag (something like [html on]) I
want to start converting everything from HTML to Word
until I find an ending bounding tag (something like [html
off].

An example:
________________________________________________________

This is some text in the Word file that is to be left
untouched. This is some text in the Word file that is to
be left untouched. This is some text in the Word file that
is to be left untouched. This is some text in the Word
file that is to be left untouched.

[html on]
<table border cellspacing=5 cellpadding=3>
<tr>
<td>some stuff</td><td>some more stuff</td><td>still more
stuff</td>
</tr>
<tr>
<td>some stuff row 2</td><td>some more stuff</td><td>still
more stuff</td>
</tr>
<tr>
<td>some stuff row 3</td><td>some more stuff</td><td>still
more stuff</td>
</tr>
</table>
[html off]

This is some text in the Word file that is to be left
untouched. This is some text in the Word file that is to
be left untouched. This is some text in the Word file that
is to be left untouched. This is some text in the Word
file that is to be left untouched.

________________________________________________________

I want the parsing and converting script/methods to work
with the straight HTML in the middle and leave everything
else untouched. What you should end up with is the
beginning and ending text and a Word table in between.

Does anyone know of an existing converter that will do
this? Seems to me that the basic functionality to convert
HTML to Word is built into Word already - is there a way
to tap into it with VBA?

Many thanks in advance...
 
W

Word Heretic

G'day "John Socolofsky" <[email protected]>,

Use Find n Replace to locate your tags. Set up ranges from the .starts
and .ends to make your chunks. The straight HTML goes into a temp file
and gets saved as html and then re-opened as a word doc and read back.


John Socolofsky said:
I would like to find a VBA method that can take a
selection within a Word file as input and convert whatever
it finds within the selection from HTML to Word format and
paste it back into the Word file in place of the HTML.

What I am trying to do is take a Word file that contains
text, bulleted lists, and images, along with straight HTML
bounded by tags. I want to parse the Word file and when I
hit a starting bounding tag (something like [html on]) I
want to start converting everything from HTML to Word
until I find an ending bounding tag (something like [html
off].

An example:
________________________________________________________

This is some text in the Word file that is to be left
untouched. This is some text in the Word file that is to
be left untouched. This is some text in the Word file that
is to be left untouched. This is some text in the Word
file that is to be left untouched.

[html on]
<table border cellspacing=5 cellpadding=3>
<tr>
<td>some stuff</td><td>some more stuff</td><td>still more
stuff</td>
</tr>
<tr>
<td>some stuff row 2</td><td>some more stuff</td><td>still
more stuff</td>
</tr>
<tr>
<td>some stuff row 3</td><td>some more stuff</td><td>still
more stuff</td>
</tr>
</table>
[html off]

This is some text in the Word file that is to be left
untouched. This is some text in the Word file that is to
be left untouched. This is some text in the Word file that
is to be left untouched. This is some text in the Word
file that is to be left untouched.

________________________________________________________

I want the parsing and converting script/methods to work
with the straight HTML in the middle and leave everything
else untouched. What you should end up with is the
beginning and ending text and a Word table in between.

Does anyone know of an existing converter that will do
this? Seems to me that the basic functionality to convert
HTML to Word is built into Word already - is there a way
to tap into it with VBA?

Many thanks in advance...

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email (e-mail address removed)
Products http://www.geocities.com/word_heretic/products.html

Replies offlist may require payment.
 

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