View Single Post
 
Old 09-26-2018, 07:37 AM
TomDW TomDW is offline Windows 10 Office 2016
Novice
 
Join Date: Sep 2018
Posts: 3
TomDW is on a distinguished road
Default Macro to remove underscores, except in email address

Hi,

I'm trying to replace all underscores in a word document with a single space, except for underscores in email addresses.
Could someone please help?
I've got the following already:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "_"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll


This will replace all underscores. I don't know how to ignore email addresses...
Thanks in advance!
Reply With Quote