We help IT Professionals succeed at work.

Extra spaces in number in Word 2007 merge field

swpa_wnt asked
I've set up a Word doc with form fields that will be used to merge numerical data from Excel.  By default, the numbers lose their comma when they appear in Word, so I added a switch to the field code. For example: { MERGEFIELD  ADJUST \# ##,### }, where ADJUST is the column name in Excel.  The use of ##,### tells Word what the maximum number of digits will be in a number, and where to place the comma.  For numbers that don't require all those digits, each unnecessary # is replaced with a space.  So, for a small number like 200, the mergefield displays "[space][space]200".  This would be fine if my numbers were in a table, but these numbers are included in sentences, and the extra spaces are not acceptable. Is there an additional switch I can add to the mergefield code that will replace each unnecessary # with NOTHING instead of a space?
Watch Question

Top Expert 2012

Try "#,##0". This will drop all leading zeros except the last one.


Hi, Graham,

Nope, no difference with that change.
I don't have leading zeros, I have leading spaces.

On edit: Ah, wait, here we go.  Instead of "##,###", I can delete the first two #s but leave the comma, so it is just ",###"  This will work for me, as none of the numbers are less than 3 digits.


Sorry, I guess my question turned into a non-issue after all. If you have no objection, Graham, I'll just delete it.


I discovered a code format that worked for my purposes.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.