Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Lilbit Lilbit is offline
external usenet poster
 
Posts: 12
Default Formatting a Form Field (Telephone Number)

Is it possible that when a user lands on a form field, that form field will
show ( )___-____. When they go to type in the telepone number, the 1st
digit will appear after the open parenthesis; after typing in the third
digit, it will jump to the 1st underlined space; after typing in three
numbers, it will jump to the 1st underlined space after the dash so they
can type in the last four numbers? Thanks!!

--
Message posted using http://www.talkaboutsoftware.com/gro...docmanagement/
More information at http://www.talkaboutsoftware.com/faq.html


  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Formatting a Form Field (Telephone Number)

I can't get this to work with parentheses, which apparently can't be
included in a "number format," but if you set the form field type to
"Number," set 12 as the maximum number of characters, and then use
000-000-0000 as the number format (checking the box for "Calculate on
exit"), users can enter numbers continuously, and when they tab out of the
field the result will be formatted as 123-456-7890. I can't help feeling
there must be some way to accomplish this with the format you want, but I
haven't been able to achieve it. It would appear not to be possible to add
formatting switches to FORMTEXT fields, so that's no help, either.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"Lilbit" wrote in message
lkaboutsoftware.com...
Is it possible that when a user lands on a form field, that form field
will
show ( )___-____. When they go to type in the telepone number, the 1st
digit will appear after the open parenthesis; after typing in the third
digit, it will jump to the 1st underlined space; after typing in three
numbers, it will jump to the 1st underlined space after the dash so they
can type in the last four numbers? Thanks!!

--
Message posted using
http://www.talkaboutsoftware.com/gro...docmanagement/
More information at http://www.talkaboutsoftware.com/faq.html





  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Formatting a Form Field (Telephone Number)

Someone is going to come up with a ridiculously simple approach that works,
but in the meantime you can do it with two macros. The first run on exit
from the telephone number form field (here Text1) and the second run on
entry to the following field. The bulk of the macros is concerned with error
trapping. The macros should allow phone numbers to be entered as 1234567890
or (123)-456-7890 but most other formats should be trapped.

Sub FormatNum()
Dim sPhone As String
Dim sNum As String
sNum = ActiveDocument.FormFields("Text1").Result
If Len(sNum) 10 Then
If Len(sNum) 10 Then
If Len(sNum) 14 And InStr(1, sNum, "(") 1 Then
MsgBox "Incorrect telephone number format." & vbCr & _
"Insert 10 digits without spaces" & vbCr & _
"For (123)-456-7890 enter 1234567890", vbCritical, _
"Number entry error"
Exit Sub
End If
End If
End If
sPhone = Format(sNum, "(000)-000-0000")
ActiveDocument.FormFields("Text1").Result = sPhone
End Sub

Sub FormatError()
Dim sNum As String
sNum = ActiveDocument.FormFields("Text1").Result
If Len(sNum) 10 Then
If Len(sNum) 14 And InStr(1, sNum, "(") 1 Then
ActiveDocument.FormFields("Text1").Select
End If
End If

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

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



Suzanne S. Barnhill wrote:
I can't get this to work with parentheses, which apparently can't be
included in a "number format," but if you set the form field type to
"Number," set 12 as the maximum number of characters, and then use
000-000-0000 as the number format (checking the box for "Calculate on
exit"), users can enter numbers continuously, and when they tab out
of the field the result will be formatted as 123-456-7890. I can't
help feeling there must be some way to accomplish this with the
format you want, but I haven't been able to achieve it. It would
appear not to be possible to add formatting switches to FORMTEXT
fields, so that's no help, either.

"Lilbit" wrote in message
lkaboutsoftware.com...
Is it possible that when a user lands on a form field, that form
field will
show ( )___-____. When they go to type in the telepone number,
the 1st digit will appear after the open parenthesis; after typing
in the third digit, it will jump to the 1st underlined space; after
typing in three numbers, it will jump to the 1st underlined space
after the dash so they can type in the last four numbers? Thanks!!

--
Message posted using
http://www.talkaboutsoftware.com/gro...docmanagement/
More information at http://www.talkaboutsoftware.com/faq.html



  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Lilbit Lilbit is offline
external usenet poster
 
Posts: 12
Default Formatting a Form Field (Telephone Number)

Thanks to both of you!!

--
Message posted using http://www.talkaboutsoftware.com/gro...docmanagement/
More information at http://www.talkaboutsoftware.com/faq.html


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch for Telephone number KarenMike Mailmerge 2 April 2nd 08 09:15 AM
Typing telephone number in the ind of line. Lion2004 Microsoft Word Help 6 August 2nd 07 05:19 PM
Switch for mail merging telephone-number field Rene Mailmerge 3 December 5th 06 06:09 AM
I don't want word splitting a telephone number when the is a - Ted C Page Layout 1 November 14th 06 10:03 PM
form field,can I add a telephone number under the number field w/d redwolfe5 Microsoft Word Help 3 March 3rd 05 06:30 PM


All times are GMT +1. The time now is 05:42 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"