Reply
 
Thread Tools Display Modes
  #1   Report Post  
macroAddict
 
Posts: n/a
Default delete duplicate commas

how do I eliminate all commas except one:
the,,,quick,brown..fox...jumps,over,the.....lazy,d og,

this doesn't work:
With ActiveDocument.Content.Find
.ClearFormatting
Do While .Execute(FindText:=",,", Forward:=True, _
Format:=True) = True
With Selection.Find
.Text = ",,"
.Replacement.Text = ","
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Loop
End With


thanks,,,,
  #2   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi ?B?bWFjcm9BZGRpY3Q=?=,

how do I eliminate all commas except one:
the,,,quick,brown..fox...jumps,over,the.....lazy,d og,

HOW doesn't it work. What kind of result are you getting?
And, which version of Word?

right off hand, I'd say you don't need the Do loop, just
Selection.Find with the Replace All. Executing twice (the
first time without specifying replacement text) is probably
driving Word bananas.

this doesn't work:
With ActiveDocument.Content.Find
.ClearFormatting
Do While .Execute(FindText:=",,", Forward:=True, _
Format:=True) = True
With Selection.Find
.Text = ",,"
.Replacement.Text = ","
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Loop
End With


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)

  #3   Report Post  
Graham Mayor
 
Posts: n/a
Default

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

Replace
,{1,}
with
,

or by macro

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ",{1,}"
.Replacement.Text = ","
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org

macroAddict wrote:
how do I eliminate all commas except one:
the,,,quick,brown..fox...jumps,over,the.....lazy,d og,

this doesn't work:
With ActiveDocument.Content.Find
.ClearFormatting
Do While .Execute(FindText:=",,", Forward:=True, _
Format:=True) = True
With Selection.Find
.Text = ",,"
.Replacement.Text = ","
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Loop
End With


thanks,,,,



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete a line created by equal signs? It won't delete from dial911book Microsoft Word Help 4 April 25th 05 01:17 PM
How do I stop Word from asking Delete Block? RodL Microsoft Word Help 1 April 20th 05 02:06 AM
delete duplicate a tmp file A Herbst Microsoft Word Help 1 April 4th 05 11:43 PM
Why did "delete" key discontinue to delete a selected word, line . Walter Microsoft Word Help 1 March 2nd 05 08:56 PM
i can not use delete key on my key board to delete text qumar Microsoft Word Help 1 December 31st 04 07:39 PM


All times are GMT +1. The time now is 12:41 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"