Auto Hyphens when a series of numbers is entered

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am looking fot guidance on how to format a specific block of user entered
data to automatically insert hypens between a specific set of numbers, such
as an account number that may look like this 90-0976-0987. I want the
hyphens to appear while the user is entering the number or after the enter
key or tab key is used.

Is there an easy way to do this or is it a matter of setting up a macro or
what.

Thanks for any assistance.
 
If the document is a protected form with text form fields, then yes, it will
require a macro. There are a couple of ways to approach this.

One method uses just a macro to format the field *after* text is entered. In
the form field's Properties dialog, you would select the macro as the Exit
macro for the field, and the field's contents would be reformatted by the
macro when the user tabs or clicks to leave the field. It isn't possible to
format the text directly in the form field while the user is entering it.

If you create a userform (a custom dialog) as explained at
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm, and select the
macro that displays the userform to be the field's Entry macro, then you can
make a text box in the userform that formats the text while it's being
entered. When the user clicks the OK button in the userform, the
entered/formatted text is transferred to the form field in the document.
Although this is a bit more complicated, the result is more user-friendly.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top