Thread: [Solved] Identifying Postcodes.
View Single Post
 
Old 09-19-2013, 02:21 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 Chayes
Thanks for the feedback. I have modified the code to take into account the formatting/line spacing issues you are experiencing. Replace the code I gave you yesterday with this one and it should resolve your issues:

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
Selection.WholeStory
With Selection.ParagraphFormat
.SpaceBefore = 0
.SpaceAfter = 0
End With
Selection.HomeKey Unit:=wdStory
End Sub

Good luck.
Tony
Reply With Quote