When you insert numbers into your document templates from data collected on your forms, you may want to assert some control over how the number look. One way to do this is to use format switches to make sure that the numbers display in the correct format. To learn more about this read this article.
However, you may also want to place a ‘format mask’ over the inserted number so that it conforms to a certain structure. You do this in Word by applying a numeric format switch to the inserted number. The syntax from the numeric format switch is ‘\#‘ followed by the format mask that you want to apply.
For example, the switch ‘\# $#,##0.00‘ in { MERGEFIELD Amount_num \# $#,##0.00 } displays a result such as “$4,455.70.” If the result of a field is not a number, this switch has no effect.
NOTE: Quotation marks are not required around simple numeric formats that do not include spaces — for example, { MERGEFIELD Number_num \# $#,##0.00 }. For more complex numeric formats and those that include text or spaces, enclose the numeric format in quotation marks, as shown in the following examples.
Available numeric format switches
You can combine the following format items to build a numeric format switch:
0 (zero)
This format item specifies the requisite numeric places to display in the result. If the result does not include a digit in that place, Word displays a 0 (zero). For example, { = 4 + 5 \# 00.00 } displays 09.00.
#
This format item specifies the requisite numeric places to display in the result. If the result does not include a digit in that place, Word displays a space. For example, { = 9 + 6 \# $### } displays $ 15.
x
This format item drops digits to the left of the “x” placeholder. If the placeholder is to the right of the decimal point, Word rounds the result to that place. For example:
{ = 111053 + 111439 \# x## } displays 492.
{ = 1/8 \# 0.00x } displays 0.125.
{ = 3/4 \# .x } displays .8.
. (decimal point)
This format item determines the decimal point position. For example, { = SUM(ABOVE) \# $###.00 } displays $495.47.
, (digit grouping symbol)
This format item separates a series of three digits. For example, { = NetProfit \# $#,###,### } displays $2,456,800.
- (minus sign)
This format item adds a minus sign to a negative result or adds a space if the result is positive or 0 (zero). For example, { = 10 – 90 \# -## } displays -80.
+ (plus sign)
This format item adds a plus sign to a positive result, a minus sign to a negative result, or a space if the result is 0 (zero). For example, { = 100 – 90 \# +## } displays +10, and { = 90 – 100 \# +## } displays -10.
%, $, *, and so on
This format item includes the specified character in the result. For example, { = netprofit \# “##%” } displays 33%.
{ Sales95 \# "$#,##0.00;-$#,##0.00" }
This format item specifies different number formats for positive and negative results, separated by a semicolon. For example, if the bookmark Sales95 is a positive value, the field { Sales95 \# “$#,##0.00;-$#,##0.00” } displays the value with regular formatting — for example, “$1,245.65”. A negative value is displayed with bold formatting and a minus sign — for example, -$ 345.56.
{ Sales95 \# "$#,##0.00;($#,##0.00);$0" }
This format item specifies different number formats for a positive result, a negative result, and a 0 (zero) result, separated by semicolons. For example, depending on the value of the Sales95 bookmark, { Sales95 \# “$#,##0.00;($#,##0.00);$0” } displays positive, negative, and 0 (zero) values as follows: $1,245.65, ($ 345.56), $0.
'text'
This format item adds text to the result. Enclose the text in single quotation marks. For example, { = { Price } *8.1% \# “$##0.00 ‘is sales tax’ ” } displays $347.44 is sales tax.
Comments
0 comments
Article is closed for comments.