logo
search
Office Settings & Configuration

How to Delete All Tables from a Word Document using VBA

Rana GarciaRana Garcia Oct 1, 2026 868 views

Question details

The user needs a method to delete every table in a Word document simultaneously, as the standard Find and Replace function does not support this action.

How to Delete All Tables from a Word Document with VBA
Product
Word
Device & OS
not provided
Scenario
Cleaning up or reformatting a document by automatically removing all existing tabular data.
Observed behavior
Word's Find and Replace feature cannot select and delete tables, requiring a manual process or an automated VBA solution.
Before you start

Save a separate backup copy of your document before running the VBA macro, as deleting all tables via a macro cannot be easily undone using the standard undo shortcut.

Solution 1Recommended

Use a VBA Macro to Delete All Tables Automatically

Running a short VBA script is the most efficient way to loop through your document and remove all tables instantly.

Because Word's standard Find and Replace tool does not target tables directly, a macro is required to loop through the document and delete them.

The script loops through the document's tables in reverse order. This ensures that deleting a table doesn't shift the index number of the remaining tables, which would otherwise cause errors during the deletion process.

1
Open the VBA Editor

Open your Word document and press the ALT + F11 keys on your keyboard simultaneously to launch the Microsoft Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the VBA editor, click on 'Insert' in the top menu bar, and then select 'Module' from the dropdown list to create a blank workspace for your code.

3
Paste the VBA Code

Copy and paste the following script into the module window: Sub DeleteAllTables() Dim i As Long With ActiveDocument.Tables For i = .Count To 1 Step -1 .Item(i).Delete Next i End With End Sub

4
Run the Macro

Click anywhere inside the pasted code and press F5 on your keyboard, or click the green 'Run Sub/UserForm' triangle button in the top toolbar. Close the VBA editor to return to your document where all tables are now removed.

Use a VBA Macro to Delete All Tables Automatically
Macro Security Settings: If the macro fails to run, ensure that your macro security settings allow scripts to execute. You may need to temporarily enable macros in the Trust Center settings.
Efficient Document Editing

Manage and Edit Word Documents Easily with WPS Office

WPS Office provides robust document formatting tools and full compatibility with Microsoft Word files, making it easy to manage large documents, adjust tables, and utilize developer tools to streamline your workflow.

  1. 1. Open your document: Launch WPS Writer and open the document containing the tables you want to manage.
  2. 2. Access Developer Tools: Navigate to the Developer tab on the top ribbon to access macro capabilities.
  3. 3. Insert the Script: Click on Macros or the Visual Basic Editor to paste and save your VBA scripts.
  4. 4. Execute the task: Run your script to instantly automate repetitive document editing tasks like deleting tables.
Fully compatible with Microsoft Word .docx and .doc formatsSupports advanced developer tools and macros for automationLightweight application with a clean, user-friendly tabbed interfaceRich set of table formatting and mass-editing features built-in
QA img-9

Frequently Asked Questions

Why can't I use Find and Replace to delete tables in Word?

The Find and Replace feature is designed to search for text strings, wildcards, and specific text formatting. It does not have a built-in parameter to select entire table objects, which is why an automated VBA script is necessary for bulk table removal.

Is there a way to delete just one specific table without a macro?

Yes, you can manually delete a single table by hovering your cursor over it, clicking the table selector icon (the small crosshair) in the top-left corner of the table, and then pressing the Backspace key.

How do I save a document that contains a VBA macro?

If you intend to keep the macro attached to the document for future use, you must 'Save As' and choose the Word Macro-Enabled Document (.docm) format. Otherwise, the script will be discarded when you save and close the standard .docx file.