WD: How to Remove HTML Tags with a Word Macro (131720)



The information in this article applies to:

  • Microsoft Word for Windows 6.0
  • Microsoft Word for Windows 6.0a
  • Microsoft Word for Windows 6.0c
  • Microsoft Word for the Macintosh 6.0
  • Microsoft Word for the Macintosh 6.0.1
  • Microsoft Word for Windows NT 6.0
  • Microsoft Word for Windows 95
  • Microsoft Word for Windows 95 7.0a

This article was previously published under Q131720

SUMMARY

This article provides a macro that selects and deletes HTML tags.

MORE INFORMATION

To remove HTML tags from your document, follow these steps:

  1. On the File menu, click Open.
  2. Click to select the Confirm Conversions check box and click your file.
  3. Click OK.
  4. In the Confirm Conversion dialog box, click Text Only.
  5. Click OK.
  6. After the document opens, run the following macro. This macro will find, select, and remove the HTML tags:
       Sub MAIN
          StartOfDocument
          EditFind .Find = "<", .Direction = 0, .MatchCase = 0, \ 
          .WholeWord = 0, .PatternMatch = 0,  .SoundsLike = 0, \ 
          .Format = 0, .Wrap = 2
          While EditFindFound()
             ExtendSelection ">"
             EditClear
             EditFind .Find = "<", .Direction = 0, .MatchCase = 0, \ 
             .WholeWord = 0, .PatternMatch = 0,  .SoundsLike = 0, \ 
             .Format = 0, .Wrap = 2
          Wend
       End Sub
    						
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties or merchantability and/or fitness for a particular purpose.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:kbhowto kbmacro kbmacroexample KB131720