Quote:
Originally Posted by macropod
Try:
Code:
Sub SpaceToUnderscore()
Application.ScreenUpdating = False
Dim StrFnd As String, StrRep As String
With Selection.Range
StrFnd = Trim(.Text)
.Case = wdTitleWord
StrRep = Replace(Trim(.Text), " ", "_")
End With
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = StrFnd
.Replacement.Text = StrRep
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
End With
Application.ScreenUpdating = True
End Sub
|
Perfect. Very very much appreciated.
I couldn’t imagine this forum without your distinct help and efforts.
Words can't describe how thankful I am
Best
Jamal