Thread: [Solved] Identifying Postcodes.
View Single Post
 
Old 09-18-2013, 03:51 AM
OTPM OTPM is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
Cut and paste this code into a module in your document and this should do the trick for you:
Sub Macro1()
'
' Macro1 Macro
'
'
Selection.HomeKey Unit:=wdStory
pCount = ActiveDocument.Paragraphs.Count
For Count = 1 To pCount
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([A-Z]{1,2})([0-9]{1,2})"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
Selection.MoveDown Unit:=wdLine, Count:=1
Next Count
End Sub

Good luck.
Tony
Reply With Quote