With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company.
Learn more about Allen...
Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Removing All Text Boxes In a Document.
If you do a lot of work with documents from other people, you may have a need to remove text boxes in those documents. If there are only one or two text boxes in the document, it is not that difficult to select them and delete them. What if there are 30, 40, or more text boxes, though? Deleting them individually can quickly get tedious.
One potential solution is a "brute force" method. Follow these steps:
Figure 1. The Paste Special dialog box.
The document text, minus the text boxes, is now in the new document. The obvious drawback to this approach is that the other formatting of the original document is also lost, and you must reformat the entire document. (I told you this was a brute force method.)
If you want to get rid of only the text boxes, then the quickest solution is to use a macro. The following macro will quickly remove all text boxes in your document:
Sub RemoveTextBox1() Dim shp As Shape For Each shp In ActiveDocument.Shapes If shp.Type = msoTextBox Then shp.Delete Next shp End Sub
You should realize that this macro removes all of the text boxes and their contents. In other words, if a text box is used for placement of text, then the text in that text box is deleted along with the text box itself.
If you prefer to transfer the text from the text boxes to the document, prior to deleting the text box, then a slight modification on the above macro will work:
Sub RemoveTextBox2() Dim shp As Shape Dim oRngAnchor As Range Dim sString As String For Each shp In ActiveDocument.Shapes If shp.Type = msoTextBox Then ' copy text to string, without last paragraph mark sString = Left(shp.TextFrame.TextRange.Text, _ shp.TextFrame.TextRange.Characters.Count - 1) If Len(sString) > 0 Then ' set the range to insert the text Set oRngAnchor = shp.Anchor.Paragraphs(1).Range ' insert the textbox text before the range object oRngAnchor.InsertBefore _ "Textbox start << " & sString & " >> Textbox end" End If shp.delete End If Next shp End Sub
When this macro is done, you can do a search for "Textbox start" and you will be at the beginning of text that used to be in the text boxes that are now gone from your document. You can then edit the text so that it appears as you want.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1690) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Removing All Text Boxes In a Document.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!