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

Re: Removing specific characters when preceded by one or more spaces by Doug

Doug
Sat Sep 09 05:45:18 CDT 2006

See the article "Finding and replacing characters using wildcards" at:

http://www.word.mvps.org/FAQs/General/UsingWildcards.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"snsd" <snsd@discussions.microsoft.com> wrote in message
news:076FFA99-5404-40A3-B021-4F7451366822@microsoft.com...
> 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



Re: Removing specific characters when preceded by one or more spaces by Helmut

Helmut
Sat Sep 09 06:03:14 CDT 2006

Hi snsd,

there are many ways to do that.
The following is only the way I am used to:

Sub Test001()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = " {2,}/"
.MatchWildcards = True
While .Execute
rDcm.Text = " /"
rDcm.Characters(1).HighlightColorIndex = wdYellow
rDcm.Collapse Direction:=wdCollapseEnd
Wend
End With
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: Removing specific characters when preceded by one or more spaces by Graham

Graham
Sat Sep 09 06:51:42 CDT 2006

Wildcard replace
[ ]@/
with
space

http://www.gmayor.com/replace_using_wildcards.htm

so
With rDcmForwardSlash.Find
.Text = " @/"
.Replacement.Highlight = True
.Replacement.Text = " "
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
snsd wrote:
> 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



RE: Removing specific characters when preceded by one or more spaces by snsd

snsd
Sat Sep 09 07:27:01 CDT 2006

Thanks guys. Works like a charm. Greatly appreciated.

"snsd" wrote:

> 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