WordRibbon.Tips.Net WordTips (Ribbon Interface)

Removing All Text Boxes In a Document

Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier 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:

  1. In your document, press Ctrl+A. The entire document is selected.
  2. Press Ctrl+C. The document is now on the Clipboard.
  3. Open a new, blank document.
  4. Make sure the Home tab of the ribbon is displayed.
  5. Click the down-arrow under the Paste tool (at the left side of the ribbon) and choose Paste Special. Word displays the Paste Special dialog box. (See Figure 1.)
  6. Figure 1. The Paste Special dialog box.

  7. In the list of formats, choose Unformatted Text.
  8. Click on OK.

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
        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. Understand, as well, that anything "special" in the text—such as tables—is converted to regular text by the macro. This means that the macro may result in a fair amount of work that needs to be done in formatted the transferred text.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9169) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Removing All Text Boxes In a Document.

Related Tips:

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

Karen Warseck    22 Nov 2016, 14:14
This is WONDERFUL!!!!!!!!!!!!

Now if you can only make it retain the formatting, I will be in heaven.
Ken Endacott    27 Jan 2016, 11:57
Why are you against textboxes?
They can be very useful.
Robert S. Rawding    25 Jan 2016, 08:42
Whose idea, in God's name, was it to "invent" text boxes anyway. This is some kind of archaic holdover from keypunch days I guess. VERY STUPID.

Jim    21 Oct 2015, 22:04
At first, the VBA did not work for me. I'm using Word 2010.

Eventually realized that the problem was that my .docx file was in Word 2007 format (compatibility mode). Once I converted it to Word 2010 format, the VBA worked!
Joe    03 Sep 2015, 10:10
Worked perfectly for me in Word 2010, Ken. Thank you.
vanda    26 Jun 2015, 09:24
yes, but still getting error in following line
Selection.TypeText(txt) - reference to a non-shared member required an object refernce


For Each shp As Microsoft.Office.Interop.Word.Shape In Document.Shapes - variable shp hides a variable in an enclosing block
Ken Endacott    25 Jun 2015, 09:10

Are you using VBA. You seem to be using VB.
vanda    25 Jun 2015, 03:28
Hi Ken Endacott,

i am sorry for so many queries, i am new to this. Please share c# code of the below macro. i am getting lots of errors like
1 - msoTextBox- does not exist in current context

2-Shape shp = default(Shape);
 foreach (shp in document.Shapes) - The type or namespace "shp" cannot be found

3 - Selection.TypeText txt; - C# equvivalent code for this line.
Please guide me. :(

vanda    25 Jun 2015, 02:17
Hi, thankyou soo much for you answer.
i getting an error on following line

1 - foreach ( shp in ActiveDocument.Shapes) - (error msg-ActiveDocument does not exist in current context)

I have added reference of following
using Microsoft.Office.Interop;
using Microsoft.Office.Tools.Word;
using Microsoft.Office.Interop.Word;

if possible please share C# code of the same. If C# is not possible then please atleast give me a solution of ActiveDocument.

Ken Endacott    24 Jun 2015, 05:41
The following macro will remove textboxes and put their content at what was the anchor point of the textbox. As it stands it works only on textboxes and not on shapes containing text frames.

Sub RemoveBoxFromText()
Dim shp As Shape
Dim txt As String
  For Each shp In ActiveDocument.Shapes
    If shp.Type = msoTextBox Then
      txt = shp.TextFrame.TextRange.Text
      Selection.TypeText txt
    End If
  Next shp
End Sub
vanda    24 Jun 2015, 04:16
i want to delete shapes and replace the content on the shape at the same postion as it is. For example - in a doc file , i have a textbox with some content. I just want to remove the textbox and want to put/insert content of textbox on the same position where the textbox was.
Hope u understood my question. Please guide me for the same.
David Lackowski    21 May 2015, 19:37
It seem like a lot of work to accomplish something that should be done much more simply. Not worth the bother!
Dianne DeSha    11 May 2015, 01:55
Thanks, Ken! Finally worked for me! :)
Ken Endacott    28 Apr 2015, 09:04
The macros have problems.

The first problem is that the macros will not delete all the textboxes in one pass because as a shape is deleted the number left decreases and ActiveDocument.Shapes.Count changes. The solution is to delete in reverse order.

The second problem is that only textboxes in the document body are deleted. There can also be textboxes in other story parts such as headers and footers.

The third problem is that text can appear in shapes other than textboxes. If the shape is a rectangle then it looks like a textbox but isn’t.

The macro below is a replacement for RemoveTextBox1. It will delete all textboxes and their contents wherever they are and delete the text only from other shapes that contain text.

Sub RemoveTextBox1()
Dim shp As Shape
Dim stry As Range
Dim oTxtFrame As TextFrame
Dim j As Long
Dim k As Long
  For Each stry In ActiveDocument.StoryRanges
    j = stry.ShapeRange.Count
    For k = j To 1 Step -1
      Set shp = stry.ShapeRange(k)
      If shp.Type = msoTextBox Then
        Set oTxtFrame = shp.TextFrame
        If oTxtFrame Is Nothing Then
         ' shape does not have a text frame
          If oTxtFrame.HasText Then
             oTxtFrame.TextRange.Text = "" ' deletes the text but not the shape
             ' shp.Delete will delete the shape including its text
          End If
        End If
      End If
    Next k
  Next stry
End Sub
Bob Fast    27 Apr 2015, 18:07
For god's sake how do you just delete an unwanted box in word??? Wthout macros, without losing formatting... just get rid of it!
Marcia    10 Apr 2015, 11:35
If you want to remove all shapes from a document, you can use this macro:

Sub RemoveAllShapes()
End Sub

The For-Each loop in the article did not work for me, but this does.
Charlotte     17 Feb 2015, 11:15
The remove formatting option worked for me using Word 2010. Thank you.
Rajiv Kamal    24 Jan 2015, 00:12
Usless stuff.

Fr name sake it removes the text box. property of the text inside text box still remains the same.

i.e. after running the macro successfully, the text behaves in the same manner.
mark    16 Jan 2015, 18:29
The Paste Special, Unformatted Text option doesn't work. I have Word 2010. Just gives me two blank pages.
Richard    12 Nov 2014, 10:07
This macro didn't work for me, either. It just blew the formatting all over the place and left the text in text boxes. Using Word 2013.
L    25 Oct 2014, 15:28
tried 3 times, it only increased the background formatting
adrian    16 Mar 2014, 19:46
Worked for me using word 2010.

Unfortunately the anchor point is the top of the page.

Is it possible to set the insertion point of the range object using 'shp.Left' and 'shp.Top' to get the text in the something like the right place?
kathy    24 Dec 2013, 15:38
This tip did not work for me. I have Word 2007. I tried the macro to remove all textboxes but leave the text.

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2017 Sharon Parq Associates, Inc.