In this article bellow, we will offer you 2 ways to batch delete brackets and the inside spaces in your Word document.
Now and then, people like to use brackets to mark words out of all kinds of purposes. Yet, after a while, you may decide to remove all brackets but only to find there are so many of them, scattering around your document. Honestly, it can take forever to delete them one by one. What’s more, out of some special need, you may have to remove all the spaces between a pair of brackets as well.
This is why you will need to read this article to equip yourself with more practical solutions.
Method 1: Use Wildcards in “Advanced Find” Command
- First of all, click “Home” tab and click the drop-down button on “Find” command.
- Next choose “Advanced Find” on the drop-down menu to open “Find and Replace” dialog box.
- For example, if you want to find all square brackets, enter “\[*\]”(without quotation marks) in “Find what” text box.
- Next click “More” button to bring out more options.
- Check “Use wildcards” box.
- Then click “Find In” tab and choose “Main Document”. You will see all square brackets and the enclosed texts are in selection, such as bellow:
- Now clear “Find what” text box and enter “[[\] ]”(without quotation marks).
- Click “Find In” and this time choose “Current Selection”. You will find all square brackets and all spaces inside are in selection as follows:
- Press “Delete” to get rid of square brackets and all spaces inside.
- However, if you want to keep spaces, just replace the strings in step 7 with “[[\]]”.
There are several sorts of commonly used delimiters in the bellowing table, together with the strings to find them or the inside spaces.
Brackets | Strings to Find Brackets and All Enclosed Texts | Strings to Find Brackets and All Spaces Inside | Strings to Find Brackets Only |
Square Brackets
[ ] |
\[*\] | [[\] ] | [[\]] |
Parentheses
( ) |
\(*\) | [(\) ] | [(\)] |
Braces (Curly Brackets)
{ } |
\{*\} | [{\} ] | [{\}] |
Angle Brackets
< > |
\<*\> | [<\> ] | [<\>] |
Method 2: Run VBA Codes
- Firstly, press “Alt+ F11” to open VBA editor.
- Next click “Normal” and then “Insert” tab.
- Choose “Module”.
- Then double click on to open it.
- And paste the following codes there:
Sub DeleteDelimiters(objFind As Find, strLeftDelimiter As String, strRightDelimiter As String, bDeleteSpace As Boolean) Dim strFind1 As String Dim strFind2 As String strFind1 = "\" & strLeftDelimiter & "*\" & strRightDelimiter If (bDeleteSpace) Then strFind2 = "[" & strLeftDelimiter & "\" & strRightDelimiter & " ]" Else strFind2 = "[" & strLeftDelimiter & "\" & strRightDelimiter & "]" End If Selection.HomeKey Unit:=wdStory objFind.ClearFormatting objFind.Replacement.Text = "" While objFind.Execute(FindText:=strFind1, MatchWildcards:=True) objFind.Execute FindText:=strFind2, MatchWildcards:=True, _ ReplaceWith:="", Replace:=wdReplaceAll, Wrap:=wdFindStop Wend End Sub Sub DeleteBracketsAndSpace() Application.ScreenUpdating = False ' Delet all square brackets and the space in it. Call DeleteDelimiters(Selection.Find, "[", "]", True) ' Delet all parenthesis and the space in it. Call DeleteDelimiters(Selection.Find, "(", ")", True) ' Delet all braces and the space in it. Call DeleteDelimiters(Selection.Find, "{", "}", True) ' Delet all angle brackets and the space in it. Call DeleteDelimiters(Selection.Find, "<", ">", Ture) Application.ScreenUpdating = True End Sub
- Now, in macro “DeleteBracketsAndSpace”, keep just the lines you need to delete the brackets you have in your document and remove all unneeded code lines.
If you want to get rid of brackets only, you need to alter the codes a little bit. Let’s say there are square brackets in your document. Then go to line “Call DeleteDelimiters(Selection.Find, “[“, “]”, True)”, and change the “True” to “False”.
- Finally, click “Run”.
Solve Word Issues
To be honest, Word is really capable of a lot of tasks. Yet, it’s not flawless after all. When there is an issue occurring, the outcome can be devastating. Therefore, we can never overlook whatever small problems in Word, since it can lead you to a dead Word with corrupt docx files. The best solution is to get an advanced repairing tool to recover your Word documents.
Author Introduction:
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xlsx repair and pdf repair software products. For more information visit www.datanumen.com
Leave a Reply