I have a macro that works to format a formfield in a label but I want to use it over and over for more than just one label. The macro puts a space between 6 characters in a postal code when the user presses tab to leave the field. It is called from the Exit event in the formfield in Word 2003 VBA. The 1st label is named "label_1", the second is "label_2", etc. The only way I can think of to have it work for each label is to write a macro for each label name but I'm sure there is an easier way. Can anyone show me how to code this?
Here's the macro I have now:
Thanks
Here's the macro I have now:
Code:
Sub FormatPostalCode()
'
' FormatPostalCode Macro
' Postal code consists of six characters with a space in the middle
' type: a1c4b5 and press tab changes it to A1C 4B5
'
ActiveDocument.FormFields("label_1").Select
strLeft = Left(Selection.Text, 3)
strRight = Right(Selection.Text, 3)
ActiveDocument.FormFields("label_1").Result = strLeft & " " & strRight
End Sub
Thanks