The following macro will convert such a string into the format that you
want:
Dim myrange As Range, mrange As Range
Selection.HomeKey wdStory
Set myrange = Selection.Paragraphs(1).Range
Selection.Find.ClearFormatting
With Selection.Find
.Execute findText:="(%)([A-Z]{2})([A-Z]{1,})",
ReplaceWith:="\2=province^p\3=CITY", Replace:=wdReplaceAll,
MatchWildcards:=True, Forward:=True, Wrap:=wdFindContinue
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Execute findText:="^", ReplaceWith:="^p", Replace:=wdReplaceAll,
MatchWildcards:=False, Forward:=True, Wrap:=wdFindContinue
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Execute findText:="$", ReplaceWith:="^p", Replace:=wdReplaceAll,
MatchWildcards:=False, Forward:=True, Wrap:=wdFindContinue
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Execute findText:="^?;", ReplaceWith:="", Replace:=wdReplaceAll,
MatchWildcards:=False, Forward:=True, Wrap:=wdFindContinue
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Execute findText:="(=)([0-9]{8})([0-9]{1,}=?+E?)",
ReplaceWith:="=Drivers LICENSE^p\2=DDMMYYYY (birth date)",
Replace:=wdReplaceAll, MatchWildcards:=True, Forward:=True,
Wrap:=wdFindContinue
End With
Set mrange = myrange.Paragraphs(3).Range
mrange.End = mrange.End - 1
mrange.InsertAfter "=NAME"
Set mrange = myrange.Paragraphs(4).Range
mrange.End = mrange.End - 1
mrange.InsertAfter "=ADDRESS"
Set mrange = myrange.Paragraphs(5).Range
mrange.End = mrange.End - 1
mrange.InsertAfter "=CITY PROVINCE POSTAL_CODE"
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP