Delete Text Box in Word — Manual Steps and C# Automation

2025-07-10 09:18:29 zaki zou

Install with Nuget

PM> Install-Package Spire.Doc

Related Links

Delete the Specific Text Box in Word Using C#

Text boxes are commonly used when creating Word documents. They help highlight content, display quotes, or enhance layout design. However, when you need to clean up or reformat a document, these text boxes may no longer be necessary. In this article, you’ll learn how to delete a text box in Word—either manually or by using C# code to remove one or all text boxes automatically.

Delete Text Boxes in Word Documents Manually with Microsoft Word

First, let's look at how to manually delete text boxes in Word documents. As one of the most widely used word processing tools, Microsoft Word makes it easy to insert and remove text boxes. Deleting a text box is a straightforward two-step process: select the text box you want to remove, then press the Delete key. Below, we will walk you through these steps in detail.

1. Steps to delete a text box in a Word file:

  • Open the Word document and locate the text box you want to remove.
  • Click the text box to select it.
  • Press the Backspace key to delete it, or use the shortcut Ctrl + X to cut it from the document.

2. Steps to batch delete text boxes in Word documents:

  • Hold down the Ctrl key on your keyboard.
  • While holding Ctrl, left-click each text box you want to delete to select them all.
  • Once selected, press the Backspace key to remove all selected text boxes at once.

Note: Make sure to click the border of each text box when selecting, not the text inside it.

Also read: How to Insert Text Box in Word Using C# >>

Delete Text Box in Word Files with C# Automatically

Manually deleting a text box in Word is easy—but what if your document contains dozens of them? Even using the Ctrl key to select multiple boxes can be time-consuming and error-prone. Fortunately, with C#, you can automate this task. Whether you need to remove a single text box or delete them all in bulk, C# makes the process fast and effortless.

In this tutorial, we'll use Spire.Doc for .NET to demonstrate how to quickly delete text boxes in Word documents through code. You can install this powerful library either by downloading it from the official website or via NuGet. It supports all the core features available in Microsoft Word—such as text editing, formatting, and layout—and even offers additional advanced capabilities for developers.

1. Delete Specific Text Box in Word with C#

Removing a specific text box in Word using C# is straightforward. The process involves three main steps: loading the document, locating the target text box, and removing it. Below is the complete code example. We'll break down how each part works right after the snippet.

Code example—Delete the first text box in Word:

using Spire.Doc;

namespace Removetextbox
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a Document instance
            Document Doc = new Document();

            // Load a Word document
            Doc.LoadFromFile("E:/Administrator/Python1/input/textbox.docx");

            // Remove the earliest inserted text box (last in the collection)
            if (Doc.TextBoxes.Count > 0)
            {
                Doc.TextBoxes.RemoveAt(Doc.TextBoxes.Count - 1);
            }

            // Save the modified document
            Doc.SaveToFile("E:/Administrator/Python1/output/removefirsttextbox.docx", FileFormat.Docx);
        }
    }
}

Result Preview: Delete the Specific Text Box in Word Using C#

Detailed steps explained:

  • Create an object of the Document class and load a Word document.
  • Remove the first text box using the Document.TextBoxes.RemoveAt() method.
  • Save the modified Word file as a new one.

Note: Due to how Word internally stores text boxes, the last one inserted appears first in the TextBoxes collection. This is not specific to Spire.Doc, but rather a result of Word’s document structure. As a result, this example uses reverse indexing to target the earliest inserted text box.

2. Batch Delete All Text Boxes in Word with C#

Compared to deleting a specific text box, removing all text boxes in a Word document with C# is much simpler. You don’t need to worry about indexes—just call the Document.TextBoxes.Clear() method to remove them all at once.

Code example—delete all text boxes in Word files at once:

using Spire.Doc;

namespace Removetextbox
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a Document instance
            Document Doc = new Document();

            // Load a Word document
            Doc.LoadFromFile("E:/Administrator/Python1/input/textbox.docx");

            // Delete all text boxes
            Doc.TextBoxes.Clear();

            // Save the modified document
            Doc.SaveToFile("E:/Administrator/Python1/output/removealltextbox.docx", FileFormat.Docx);
        }
    }
}

The Conclusion

In this article, we explored how to delete text boxes in Word documents—both manually and programmatically using C#. Whether you need to remove a single text box or clear them all, this guide has you covered. For documents with only a few text boxes, manual deletion works just fine. But if you're dealing with a large number of them, automating the task with C# is a much more efficient solution.


FAQs about Deleting Text Boxes in Word

Q1: How do I remove a text box from a Word document?

To remove a text box manually, click on its border to select it, then press the Backspace or Delete key on your keyboard. You can also right-click and choose “Cut” or use the shortcut Ctrl + X.

Q2: Can I delete all text boxes in a Word document at once using C#?

Yes. If you're working with multiple text boxes, using C# is an efficient way to delete them all at once. With the Spire.Doc for .NET library, you can simply call Document.TextBoxes.Clear() to remove every text box in the document programmatically.

Q3: How do I remove an anchored text box in Word?

Anchored text boxes are linked to a specific paragraph or location in the document. You can delete them the same way as regular text boxes—just click on the border of the box (not inside the text), then press Delete. For precise control, you can also use C# to locate and remove them programmatically.


ALSO READ: