View Single Post
 
Old 02-08-2024, 01:42 AM
yacov yacov is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Oct 2019
Posts: 146
yacov is on a distinguished road
Default clean extra space

Hello,
I tried to change the macro below so that in one run it will delete an unnecessary space next to the + - signs
Is it possible?
I can duplicate the macro and put one mark per macro but that leaves me with a lot of shortcuts.
Thanks

Sub MFindReplacePARA()
Dim aDoc As Document, strFindText As String, strReplaceText As String
strFindText = "^p^p"
strReplaceText = "^p"
strFindText = " +"
strReplaceText = "+"
strFindText = "+ "
strReplaceText = "+"
strFindText = "- "
strReplaceText = "-"
strFindText = " -"
strReplaceText = "-"
For Each aDoc In Application.Documents
With aDoc.Range.Find
.Text = strFindText
.Replacement.Text = strReplaceText
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Next aDoc
End Sub
Reply With Quote