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.
by Allen Wyatt
(last updated November 7, 2015)
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.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
When using a macro to format text, you can set all sorts of attributes for paragraphs or individual characters. On ...Discover More
One of the basic programming structures used in VBA is the While ... Wend structure. This structure helps to make the ...Discover More
Part of developing macros is learning how to use and manipulate variables. This tip examines a technique you can use to ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.