A family of Microsoft word processing software products for creating web, email, and print documents.
Hello
I’m Adeyemi and I’d be happy to help you with your question.
The script you provided is a VBA macro that removes the text before the colon and replaces it with spaces to align the text. Here's a cleaner version of the script that does the same thing:
Sub Delete\_Starters()
Dim rng As Range
Set rng = ActiveDocument.Range
With rng. Find
. ClearFormatting
. Text = "[0-9]{1,}[a-z]{1,}:"
. Replacement.Text = " "
. Forward = True
. Wrap = wdFindStop
. Format = False
. MatchCase = False
. MatchWholeWord = False
. MatchAllWordForms = False
. MatchSoundsLike = False
. MatchWildcards = True
. Execute Replace:=wdReplaceAll
End With
End Sub
This version of the script uses the Replace parameter of the Execute method to replace all occurrences of the text matching the search pattern with spaces. This eliminates the need for a loop and makes the code shorter and easier to read.
I hope this helps!
Give back to the Community. Help the next person who has this issue by indicating if this reply solved your problem. Click Yes or No below
Regards Adeyemi