Thread: [Solved] Macro to delete tabs in Word
View Single Post
 
Old 12-16-2020, 08:29 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,382
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmaxey View Post
If you want a macro that simply deletes all but the first tab in each paragraph of text, you could use:
Alternatively, and usually much quicker than looping through all paragraphs:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  .InsertBefore vbCr
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "(^13[!^13]@^t[!^13]@)^t"
    .Replacement.Text = "\1 "
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
  End With
  Do While .Find.Execute = True
    .Find.Execute Replace:=wdReplaceAll
  Loop
  .Characters.First.Text = vbNullString
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote