View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Format National Insurance Number

As far as I am aware, there is no simple way to do this.

The options a
1. Format it correctly in the Excel data file
or.
2. Derive three additional fields from the NI field using LEFT RIGHT and MID
functions in Excel to separate the three parts of the number i.e. 2 letters
6 numbers 1 letter and merge those fields - wherein you can format the
number field in Word with a switch
http://www.gmayor.com/formatting_word_fields.htm
or
3. Merge to a new document and run a macro to format the number:

Sub FormatNI()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([A-Z]{2})([0-9]{2})([0-9]{2})([0-9]{2})([A-Z])"
.Replacement.Text = "\1 \2 \3 \4 \5"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


M-Hop wrote:
I am using an excel record for mailmerge and would like to format a
national insurance record. The text field is for example AA112233B,
and I would like to merge the field divided into separated segments
eg. AA 11 22 33 B. Dates and numerical data are fine, but I'm
not sure exactly what is needed for alpha-numeric?