![]() |
|
#6
|
||||
|
||||
|
Hi Michael,
Try: Code:
Sub Demo()
Application.ScreenUpdating = False
Dim strFind As String, strRep As String, i As Integer
strFind = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,morning,afternoon,evening,midnight,"
strFind = strFind & "knots,knots,becoming,north,south,east,west"
strRep = "Mon,Tue,Wed,Thu,fri,Sat,Sun,AM,PM,Evng,Mnght,"
strRep = strRep & "KT,KT,bcmg,N,S,E,W"
With ActiveDocument.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
.Text = "^13"
.Replacement.Text = "^l"
.Execute Replace:=wdReplaceOne
.Text = "([^13]{2}[!^13]{1,})^13"
.Replacement.Text = "\1^l"
.Execute Replace:=wdReplaceAll
.Text = "Periods*([^13]{2})"
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
.Text = "([ ]{1,})(^13)"
.Replacement.Text = "\2"
.Execute Replace:=wdReplaceAll
.Text = "([!^13])(^13)([!^13])"
.Replacement.Text = "\1\3"
.Execute Replace:=wdReplaceAll
.Text = "([0-9]) to ([0-9])"
.Replacement.Text = "\1-\2"
.Execute Replace:=wdReplaceAll
.MatchWildcards = False
.MatchCase = False
For i = 1 To UBound(Split(strFind, ","))
.Text = Split(strFind, ",")(i)
.Replacement.Text = Split(strRep, ",")(i)
.Execute Replace:=wdReplaceAll
Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] Last edited by macropod; 12-31-2010 at 08:21 PM. Reason: Added word string array to simplify coding. |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Undo Delete | jbelorit | Outlook | 0 | 11-22-2010 08:10 AM |
| delete email message via blackberry and have it delete on my pop3 and my outlook | Iamthestorm | Outlook | 2 | 10-28-2010 12:21 AM |
| Highlighted text won't delete - when I press enter | Gague | Word | 2 | 07-09-2010 12:53 PM |
| Some emails will not delete | Shawn76 | Outlook | 0 | 07-01-2010 01:33 PM |
| Need to delete style and style text | mclan | Word | 0 | 08-04-2008 12:05 PM |