How to remove tabs used to indent paragraphs in a Word document


Sometimes you want to remove those tabs that indent your paragraphs. But in a long document, that could be a nightmare. Here are two quick solutions.

word-illustration.jpg
Illustration: Lisa Hornung, Getty Images/iStockPhoto

Many Microsoft Word users insert a tab at the beginning of each paragraph. In a one-off document, it won’t usually matter, but in a document that’s often updated, these tabs can cause trouble. Even if not, you might prefer block style, which uses no indent at the beginning of each paragraph. Regardless of how the tabs got there, you might want to remove them. In this article, I’ll show you two ways to remove a tab at the beginning of each paragraph: Replace and a VBA procedure.

SEE: 83 Excel tips every user should master (TechRepublic)

I’m using Microsoft 365 on a Windows 10 64-bit system. (I recommend that you not upgrade to Windows 11 until all the kinks are worked out unless you have a specific reason for doing so.) For your convenience, you can download the demonstration .docm, .doc, and .cls files. Word Online doesn’t support macros or the special Replace codes.

How to remove tabs using Replace in Microsoft Word

In a long document, nobody has the time to manually delete a tab used to indent every paragraph in the document. Besides being tedious, it isn’t a good use of your time. Fortunately, you can use Word’s Replace feature if you know the special codes to use:

  • ^p represents the paragraph mark
  • ^t represents a tab

In this case, searching for every tab using ^t alone won’t work because doing so would find every tab instead of only the tabs following a paragraph mark. Let’s work through a quick example using the document shown in Figure A:

  1. On the Home tab, click the Editing dropdown in the Editing group and then choose Replace.
  2. In the Find What control enter ^p^t.
  3. In the Replace With control enter ^p (Figure A).
  4. Click Replace All.
  5. When prompted, confirm the task (twice, if necessary).

Figure A

We’ll use Replace to remove any tab at the beginning of a paragraph.

As you can see, I’ve enabled Show/Hide (on the Home tab in the Paragraph group) so you can see the tab and paragraph marks.

Figure B shows the resulting document; only one tab wasn’t removed. In plain English, this task says: When encountering a paragraph mark followed by a tab, replace both characters with only a paragraph mark. The tab must be preceded by a paragraph mark. The first tab in the document doesn’t fulfill that requirement. Manually removing that one tab doesn’t seem so bad when you realize you’re not deleting dozens or even hundreds of tabs manually.

Figure B

The Replace task removed all the tabs but one.

If this doesn’t work for you, click the More button and replace the manually entered codes using the Special button. Sometimes Word is a bit finicky and won’t evaluate codes entered via the keyboard. The only real limitation is remembering how to correctly use the codes. If you’re supporting users who might not have this skill, you can provide a VBA sub procedure instead.

How to remove tabs using VBA in a Word document

If requiring users to remember how to use Replace in this way is asking a bit too much, provide them with a VBA solution. All they have to remember to do is run the procedure, and you can add it to a group on the ribbon or the Quick Access Toolbar (QAT) making access quick and easy. Listing A is the sub procedure we’ll use.

Listing A
Sub RemoveTabs()

'Remove all tabs following a paragraph mark.

'Removes tabs used to indent paragraphs.

Selection.Find.ClearFormatting

Selection.Find.Replacement.ClearFormatting

With Selection.Find

.Text = "^p^t"

.Replacement.Text = "^p"

.Forward = True

.Wrap = wdFindContinue

.Format = False

.MatchCase = False

.MatchWholeWord = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

End With

Selection.Find.Execute Replace:=wdReplaceAll
End Sub

To enter the procedure, press Alt + F11 to open the Visual Basic Editor (VBE). In the Project Explorer to the left, select ThisDocument, as shown in Figure C. You can enter the code manually or import the downloadable .cls file. In addition, the macro is in the downloadable .docm, .doc, and .cls files. If you enter the code manually, don’t paste from this web page. Instead, copy the code into a text editor and then paste that code into the ThisDocument module. Doing so will remove any phantom web characters that might otherwise cause errors.

Figure C

Enter the procedure into ThisDocument.

After entering the procedure, return to the document. If you are using a ribbon version, be sure to save the workbook as a macro-enabled file. If you’re working in the menu version, you can skip this step.

If you’re using the demonstration file, you might want to press Ctrl + Z to undo the tab deletes from the last section so you can see the procedure remove them. To run the procedure, click the Developer tab. In the Code group, click Macros. In the resulting dialog, select RemoveTabs (Figure D) and click Run. Now, you won’t want to ask users to work quite this hard to run this procedure. To learn how to add the procedure to a custom group on the ribbon or the QAT, read How to add Office macros to the QAT toolbar for quick access.

Figure D

Choose the procedure and click Run.

Whether you use Replace or the VBA procedure, remember that neither will find that first tab in the document. However, it should find all the other instances of a tab following a paragraph mark. If you’re uncertain, you might click Replace and Next for a few instances until you feel more comfortable replacing them all at the same time.



Source link