S
snsd
Hi: I want to remove the forward slash from a document if and only if it is
preceded by one or more spaces. i.e. “abc/†is OK but “ /†or “ /†or “
/abcâ€â€¦ is not. The following code successfully removes the forward slash
character that is preceded by a single space from a document and replaces it
with a highlighted space. So if there are 2 or more…spaces before the forward
slash, I want it to be removed and replaced with a highlighted space. (I am
fine with all the spaces being removed and simply replacing the entire string
with a single space.) What do I need to do to modify the code to accomplish
such? Any help is greatly appreciated.
'Removes / proceeded by a single space and replaces with a highlighted space
Dim rDcmForwardSlash As Range
Set rDcmForwardSlash = ActiveDocument.Range
With rDcmForwardSlash.Find
.Text = " /"
.Replacement.Highlight = True
.Replacement.Text = " "
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
preceded by one or more spaces. i.e. “abc/†is OK but “ /†or “ /†or “
/abcâ€â€¦ is not. The following code successfully removes the forward slash
character that is preceded by a single space from a document and replaces it
with a highlighted space. So if there are 2 or more…spaces before the forward
slash, I want it to be removed and replaced with a highlighted space. (I am
fine with all the spaces being removed and simply replacing the entire string
with a single space.) What do I need to do to modify the code to accomplish
such? Any help is greatly appreciated.
'Removes / proceeded by a single space and replaces with a highlighted space
Dim rDcmForwardSlash As Range
Set rDcmForwardSlash = ActiveDocument.Range
With rDcmForwardSlash.Find
.Text = " /"
.Replacement.Highlight = True
.Replacement.Text = " "
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With