![]() |
|
#2
|
||||
|
||||
|
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
Set Rng = ActiveDocument.Range
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = True
.Forward = True
.Wrap = wdFindStop
.Text = "abc"
.Style = "one_car"
.Replacement.Text = ""
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
.MoveStart Unit:=wdCharacter, Count:=-3
.InsertBefore ","
.Collapse wdCollapseEnd
.Find.Execute
Loop
.Start = Rng.Start
With .Find
.Text = ""
.Execute
End With
Do While .Find.Found
.InsertAfter "."
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = True
.Forward = True
.Wrap = wdFindStop
.Text = "abc"
.Style = "one_car"
.Replacement.Text = ""
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
.MoveStart Unit:=wdCharacter, Count:=-3
.InsertBefore ","
.Collapse wdCollapseEnd
.Find.Execute
Loop
With .Find
.Text = ""
.Replacement.Text = "^&."
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to a For loop in VBA
|
Jennifer Murphy | Word VBA | 1 | 01-29-2013 03:30 AM |
| How to use for loop in formula in VBA? | tinfanide | Excel Programming | 1 | 12-06-2011 08:33 AM |
| While loop not working right | Cbrehm | Excel Programming | 0 | 05-11-2011 11:05 AM |
Alter right click menu?
|
markg2 | Office | 1 | 01-10-2011 08:10 AM |
Continuous Loop
|
cksm4 | Word | 6 | 01-06-2011 09:03 PM |