In this article, we are delighted to provide you with the method to clear a specific table style in your Word document.
Normally, in a document, there can be lots of document, applied with different styles. And we have explained ways to clear all table styles in one of our previous article. For detailed information, you can refer to this link: 3 Useful Methods to Batch Clear All Table Styles in Your Word Document
Now let’s see how to clear a particular table style from your Word document.
Method 1: Clear a Specific Table Style in One Document
- First of all, press “Alt+ F11” to trigger the VBA editor in Word.
- Then on the left column of the editor, click the “Normal” project.
- Next click the “Insert” on menu bar.
- On the drop-down menu, choose “Module”.
- Now you have inserted a module. Double click it to open its coding area and paste these codes there:
Sub ClearASpecificTableStyle() Dim objTable As Table Dim objDoc As Document Dim strStyleName As String Application.ScreenUpdating = False Set objDoc = ActiveDocument strStyleName = InputBox("Enter the name of table style which you want to clear: ", "Specify Table Style") For Each objTable In objDoc.Tables If objTable.Style = strStyleName Then objTable.Style = "Table Normal" objTable.Borders.Enable = True End If Next objTable Application.ScreenUpdating = True Set objDoc = Nothing End Sub
- Then either click “Run” or hit “F5” to execute codes.
- Now in the “Specify Table Style” box, enter the name of the style which you want to remove from the document.
- And click “OK” to move on.
Here is the possible result:
Method 2: Clear a Specific Table Style in Multiple Documents
Now in case there is a batch of files to process, you can utilize the following macro.
- To begin with, put all target documents in one same folder.
- Then repeat steps in method 1 to install and run a macro.
- But remember to replace macro with this one:
Sub ClearASpecificTableStyleInMultiDoc() Dim objTable As Table Dim objDoc As Document Dim StrFolder As String Dim strFile As String Dim strStyleName As String Dim dlgFile As FileDialog Set dlgFile = Application.FileDialog(msoFileDialogFolderPicker) With dlgFile If .Show = -1 Then StrFolder = .SelectedItems(1) & "\" Else MsgBox "Select a folder first." Exit Sub End If End With strStyleName = InputBox("Enter the name of table style which you want to clear: ", "Specify Table Style") strFile = Dir(StrFolder & "*.docx", vbNormal) While strFile <> "" Set objDoc = Documents.Open(FileName:=StrFolder & strFile) Set objDoc = ActiveDocument For Each objTable In objDoc.Tables If objTable.Style = strStyleName Then objTable.Style = "Table Normal" objTable.Borders.Enable = True End If Next objTable objDoc.Save objDoc.Close strFile = Dir() Wend End Sub
- Next, there is the “Browse” window open. Just pick the folder you keep target documents and click “OK” to move on.
- Then there is the “Specify Table Style” box. Input style name and click “OK” to proceed.
Deal with Document Errors
There is always the possibility of getting Word broken. And the most devastating thing could be losing you valuable documents. Therefore, you must seize time to get a tool to fix Word in no time once the disaster happens.
Author Introduction:
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xls recovery and pdf repair software products. For more information visit www.datanumen.com
Leave a Reply