Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 12-31-2010, 08:06 PM
macropod's Avatar
macropod macropod is offline Delete text Windows 7 32bit Delete text Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,536
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
The macro does the initial F/R you asked for, as well as a bunch of other cleaning up, including the AM/PM changes you mentioned. If you want to process additional words, simply add them and their replacements to the strFind and strRep variables.
__________________
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.
Reply With Quote
 



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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2026 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft