What this macro does:
This macro will search through an entire HTML document and strip (delete) all instances of any one type of HTML tag. I designed it to remove all <IMG> tags from a document and leave all else untouched, but it can also be used to remove other tags besides <IMG>.
The very first line of code causes MS Word to display an Input Box to the user. The Input Box asks the user to enter the name of an HTML tag. The user is then expected to type in something like IMG, P, BR, HR, META, or LINK. Once the user has specified the name of the HTML tag to be searched for, the macro uses the Find command (aka Find method or Find property) to locate all occurrences of the tag and subsequently delete them. If no such tags were found within the document, then the user will receive a message similar to:
"No <IMG> tag was found."
This macro works best for "open-ended" HTML tags. Open-ended HTML tags are those which are "self-contained," in a sense. They have no corresponding closing tag. For example, <B> is not an open-ended tag, because it requires the </B> closing tag. A web designer places text in between a <B> tag and a </B> tag. On the other hand, <IMG> is an open-ended HTML tag, because the <IMG> tag contains all of the necessary information within itself, such as in <IMG SRC="picture.jpg">. No corresponding closing tag is necessary. In fact, there is no such thing as a </IMG> closing tag.
If you wish to use this macro to remove paired HTML tags, such as B, I, U, FONT, TABLE, etc, then you have two options:
1. Modify the macro code.
2. Run the macro twice.
If you choose to run the macro twice, then on the first run you will enter B (for example), and on the second run you will enter /B.
Thanks for reading about my macro!
-Kelly