|
What these macros do:
These macros are designed to remove text boxes from a document. The main text of the document, as well as all other parts of the document, will be left unchanged.
"Text box" can be an ambiguous term within the context of Microsoft Word. Therefore, I must clarify which kind of text box will be deleted. The two macros on this web page will delete the type of text box that is created using the "Drawing" toolbar. This is also the same type that can be created by choosing "Insert" then "Text Box" using the main menu bar at the top of the Word application screen. This macro will NOT delete Text Form Fields, which are inserted using the "Forms" toolbar. (If the Drawing toolbar and/or Forms toolbar are not displayed in your Word window and you would like to display them, just right-click while your mouse cursor is over any other Word menu or toolbar, and then select "Drawing" or "Forms" from the list that appears.)
These macros are very short and straightforward. The second macro especially (Sub Remove_ALL_TextBoxes) requires little to no explanation. Remove_ALL_TextBoxes does exactly as I have stated: it will remove each and every text box from a document.
The first macro (Sub RemoveBoxesContainingCertainText), on the other hand, requires clarification on just a few tiny points. First of all, as it is written now, the macro will only delete a text box if the text box contains the word "draft." Note: the function used to find the word "draft" will use a non case-sensitive (or "case insensitive") search. Therefore, if one text box says "draft" and another says "DRAFT" or "Draft," they will all be deleted.
To search for a word or string of characters other than "draft," you only need to make one tiny change to the macro code. Simply delete draft from the fifth line of programming code, and replace it with any word or phrase or character of your choosing. Be sure to leave the quotation marks and the commas exactly as they are. Only replace or change what is between the two quotation marks that originally contained draft.
Also, please be aware of the following: the RemoveBoxesContainingCertainText macro checks to see if your search string (for example, "draft") is found anywhere within the text box. So if one text box says "Draft 1" and another says "Rough Draft," both text boxes will be deleted because the string "draft" was located within the text. This can become progressively more confusing depending on the circumstances of your document. For example, say you have three text boxes that each contain the name of an animal. One says "Cat," one says "Dog," and one says "Catfish." If you run the macro to delete any box with "Cat," then you must be aware that the box with "Catfish" will be deleted also!
So... make sure you use good search logic, and then delete away!
Thanks for reading about my macro!
-Kelly |