Delete Word Tables with Empty Content Controls Using a Macro
Question details
Create a Word macro that removes tables containing unanswered rich-text content controls.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A Word template contains tables with rich-text content controls that users may leave unanswered.
- Observed behavior
- Unanswered controls display placeholder text, and the user wants to remove their associated tables.
Use desktop Word and test the macro on a copy containing examples of each table structure. Decide whether an unanswered control should remove the whole table or only its row; the macro below removes the whole table.
Run a VBA macro to remove tables with placeholder controls
Use this approach when any unanswered rich-text content control should cause its entire table to be deleted.
The macro checks tables returned by ActiveDocument.Tables and deletes a table if any rich-text content control in its range is still showing placeholder text. Other answers in that table will also be deleted, so review mixed-content and nested-table cases before use.
This check relies on Word's ShowingPlaceholderText property. It does not identify every control that has been manually cleared or contains only whitespace.
In Word, open the test document and select Review > Restrict Editing > Stop Protection if editing is restricted. Enter the password if prompted.
Press Alt+F11 to open the VBA editor, select Insert > Module, and paste the following code: Sub DeleteTablesWithUnansweredControls() Dim doc As Document Dim tbl As Table Dim cc As ContentControl Dim i As Long Dim deleteTable As Boolean Set doc = ActiveDocument If doc.ProtectionType <> wdNoProtection Then MsgBox "Remove document protection before running this macro." Exit Sub End If For i = doc.Tables.Count To 1 Step -1 Set tbl = doc.Tables(i) deleteTable = False For Each cc In tbl.Range.ContentControls If cc.Type = wdContentControlRichText Then If cc.ShowingPlaceholderText Then deleteTable = True Exit For End If End If Next cc If deleteTable Then tbl.Delete Next i End Sub
Return to Word, press Alt+F8, select DeleteTablesWithUnansweredControls, and click Run. Check each affected table and the surrounding paragraph marks.
If the document was protected before editing, open Review > Restrict Editing, choose the appropriate restrictions, and select Yes, Start Enforcing Protection.

Edit Word tables in WPS Writer
WPS Writer is a free, lightweight Office alternative with a familiar interface for opening and editing Word documents. You can review and delete unwanted tables manually, though it does not fix or guarantee compatibility with a Microsoft Word VBA macro.

Frequently Asked Questions
Does the macro delete a row or the whole table?
It deletes the entire table when any rich-text control in that table's range is showing placeholder text. A row-only solution requires different logic and testing for your table layouts.
What if a content control is blank but no placeholder appears?
The macro uses ShowingPlaceholderText, so it may not flag a manually cleared or whitespace-only control. Review those controls separately or adapt the check to your template.
Why does the macro ask me to remove protection?
Protected documents can prevent table deletion. In Word, use Review > Restrict Editing > Stop Protection, run the macro, and then restore the required protection.
Can deleting a table change the spacing around it?
Yes. Inspect the paragraph marks around deleted tables after running the macro. Use paragraph or style settings to adjust spacing rather than automatically removing consecutive paragraph marks.




