Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA to remove HTML code in Microsoft Word

Status
Not open for further replies.

WOP29

Technical User
Aug 2, 2011
5
US
I have the following HTML code that I would like to remove if one of the criteria is blank. The following part below were it shows "yes'>10</span>"...if there is nothing there I would like to remove it.

style='mso-no-proof:
yes'>10</span></span><!--[if supportFields]><span style='font-size:10.0pt;

Likewise if the following part were it say Economic is blank please remove the whole HTML listed at the bottom of the page:

"</span>Economics<span"
mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>Economics</span>"


partial HTML CODE that I need to remove if criteria above exist

<tr style='mso-yfti-irow:1'>
<td width=143 valign=top style='width:107.45pt;border:solid black 1.0pt;mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt; mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor: text1;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><!--[if supportFields]><span style='font-size:10.0pt; mso-bidi-font-size:11.0pt'><span style='mso-element:field-begin'></span><span style='mso-spacerun:yes'> </span>Economics<span style='mso-element:
field-separator'></span></span><![endif]--><span style='font-size:10.0pt;
mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>Economics</span></span><!--[if supportFields]><span
style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span style='mso-element:
field-end'></span></span><![endif]--><span style='font-size:10.0pt;
mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
</td>
<td width=72 valign=top style='width:54.15pt;border-top:none;border-left:
none;border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;
border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:
solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;
mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:
text1;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal align=center style='text-align:center'><!--[if supportFields]><span
style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span style='mso-element:
field-begin'></span><span style='mso-spacerun:yes'> </span>MERGEFIELD Quantity_
<span style='mso-element:field-separator'></span></span><![endif]--><span
style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span style='mso-no-proof:
yes'>10</span></span><!--[if supportFields]><span style='font-size:10.0pt;
mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span><![endif]--><span
style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
</td>
 
I can't give you a total solution at this point, but as a starting point, I'd say look into using Find in Word VBA.

I don't have time to help sort it out and provide it at the moment, but that's where I'd start searching.

Also, since you know this is a VBA question, then you need to post the question in the VBA forum:
forum707
 
Word and HTML - does not compute well...

I'd recommend you save this document as .doc, open it in OpenOffice and save as HTML from there. This should rid you of a great deal of superfluous coding.

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top