Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
I am attempting to determine the format code i need to enter in a numeric
form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
Run a macro containing the following code on exit from the formfield (Change
the Text1 to the bookmark name assigned to the formfield) Dim IntPart as String, DecPart as String With ActiveDocument.FormFields("Text1") If IsNumeric(.result) Then If InStr(.result, ".") 0 Then IntPart = Left(.result, InStr(.result, ".") - 1) DecPart = Mid(.result, InStr(.result, ".")) If Len(DecPart) = 2 Then DecPart = DecPart & "0" End If Else IntPart = .result DecPart = ".00" End If Select Case Len(IntPart) Case Is 4 IntPart = IntPart Case 4 IntPart = Left(IntPart, 1) & " " & Mid(IntPart, 2) Case 5 IntPart = Left(IntPart, 2) & " " & Mid(IntPart, 3) Case 6 IntPart = Left(IntPart, 3) & " " & Mid(IntPart, 4) Case 7 IntPart = Left(IntPart, 1) & " " & Mid(IntPart, 2, 3) & " " & Mid(IntPart, 5) Case 8 IntPart = Left(IntPart, 2) & " " & Mid(IntPart, 3, 3) & " " & Mid(IntPart, 6) Case 9 IntPart = Left(IntPart, 3) & " " & Mid(IntPart, 4, 3) & " " & Mid(IntPart, 7) End Select .result = IntPart & DecPart Else MsgBox "You have not entered a number" End If End With From the above you should be able to deduce the results to be used for cases where the length of the integer part of the number is greater than 9 digits. -- 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, originally posted via msnews.microsoft.com "Owen" wrote in message ... I am attempting to determine the format code i need to enter in a numeric form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
Doug
That is brilliant, not sure i'll ever grasp the Visual Basic concept like you guys on here, but i'll keep having a crack. Thanks also to Macropod and Graham for your replies. "Doug Robbins - Word MVP" wrote: Run a macro containing the following code on exit from the formfield (Change the Text1 to the bookmark name assigned to the formfield) Dim IntPart as String, DecPart as String With ActiveDocument.FormFields("Text1") If IsNumeric(.result) Then If InStr(.result, ".") 0 Then IntPart = Left(.result, InStr(.result, ".") - 1) DecPart = Mid(.result, InStr(.result, ".")) If Len(DecPart) = 2 Then DecPart = DecPart & "0" End If Else IntPart = .result DecPart = ".00" End If Select Case Len(IntPart) Case Is 4 IntPart = IntPart Case 4 IntPart = Left(IntPart, 1) & " " & Mid(IntPart, 2) Case 5 IntPart = Left(IntPart, 2) & " " & Mid(IntPart, 3) Case 6 IntPart = Left(IntPart, 3) & " " & Mid(IntPart, 4) Case 7 IntPart = Left(IntPart, 1) & " " & Mid(IntPart, 2, 3) & " " & Mid(IntPart, 5) Case 8 IntPart = Left(IntPart, 2) & " " & Mid(IntPart, 3, 3) & " " & Mid(IntPart, 6) Case 9 IntPart = Left(IntPart, 3) & " " & Mid(IntPart, 4, 3) & " " & Mid(IntPart, 7) End Select .result = IntPart & DecPart Else MsgBox "You have not entered a number" End If End With From the above you should be able to deduce the results to be used for cases where the length of the integer part of the number is greater than 9 digits. -- 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, originally posted via msnews.microsoft.com "Owen" wrote in message ... I am attempting to determine the format code i need to enter in a numeric form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
Hi Owen,
If you make the formfield type numeric, you can specify the number format as: ### ### ##0.00 -- Cheers macropod [Microsoft MVP - Word] "Owen" wrote in message ... I am attempting to determine the format code i need to enter in a numeric form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
You could do that but you are reliant on the user entering the decimal. Try
it with 12345 -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org macropod wrote: Hi Owen, If you make the formfield type numeric, you can specify the number format as: ### ### ##0.00 "Owen" wrote in message ... I am attempting to determine the format code i need to enter in a numeric form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
Hi Graham,
Works for me - 12345 gets displayed as 12 345.00, which accords with the OP's requirement (I always require two decimal places, even if the user only inputs the integer value). -- Cheers macropod [Microsoft MVP - Word] "Graham Mayor" wrote in message ... You could do that but you are reliant on the user entering the decimal. Try it with 12345 -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org macropod wrote: Hi Owen, If you make the formfield type numeric, you can specify the number format as: ### ### ##0.00 "Owen" wrote in message ... I am attempting to determine the format code i need to enter in a numeric form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
How odd - here I get 12 3.45 in both Word 2003 and 2007 using that switch?
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org macropod wrote: Hi Graham, Works for me - 12345 gets displayed as 12 345.00, which accords with the OP's requirement (I always require two decimal places, even if the user only inputs the integer value). "Graham Mayor" wrote in message ... You could do that but you are reliant on the user entering the decimal. Try it with 12345 -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org macropod wrote: Hi Owen, If you make the formfield type numeric, you can specify the number format as: ### ### ##0.00 "Owen" wrote in message ... I am attempting to determine the format code i need to enter in a numeric form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form Field Number Format Problem
Same here, even if I modify the digit grouping symbol in the Control
PanelRegional and Language Options. It was only after trying all sorts of formatting switches that I resorted to creating the macro. Wait a minute, it does work if you use Ctrl+Shift+Spacebar to insert the space in the formatting switch # ##0.0 Also, the switch shown above is all that is required no matter how many digits are contained in the number -- 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, originally posted via msnews.microsoft.com "Graham Mayor" wrote in message ... How odd - here I get 12 3.45 in both Word 2003 and 2007 using that switch? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org macropod wrote: Hi Graham, Works for me - 12345 gets displayed as 12 345.00, which accords with the OP's requirement (I always require two decimal places, even if the user only inputs the integer value). "Graham Mayor" wrote in message ... You could do that but you are reliant on the user entering the decimal. Try it with 12345 -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org macropod wrote: Hi Owen, If you make the formfield type numeric, you can specify the number format as: ### ### ##0.00 "Owen" wrote in message ... I am attempting to determine the format code i need to enter in a numeric form field. The following are my parameters: The format i am trying to achieve is: ### ### ###.## I always require two decimal places, even if the user only inputs the integer value. I require a space between each 3 consecutive digits. I do not want to show any leading zeros. For example, the formatted fields appear as 456 345.23 2 456 345.23 Thanks in advance for any help, i do not seem to be able to achieve the desired result through using # or 0 or any combination of them. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Format form field for phone number | Microsoft Word Help | |||
puzzling number format problem in conditional field | Mailmerge | |||
form field format for phone number | Microsoft Word Help | |||
Syntax for Number format in the Text Form Field Options | Microsoft Word Help | |||
form field,can I add a telephone number under the number field w/d | Microsoft Word Help |