View Single Post
 
Old 03-08-2013, 04:31 AM
Jamal NUMAN Jamal NUMAN is offline Windows 7 64bit Office 2010 64bit
Expert
 
Join Date: Nov 2010
Posts: 615
Jamal NUMAN is on a distinguished road
Thumbs up

Quote:
Originally Posted by macropod View Post
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
Attached Images
File Type: jpg Clip_385.jpg (96.7 KB, 11 views)
File Type: jpg Clip_386.jpg (50.6 KB, 11 views)
Reply With Quote