Another way of doing it would be to use a field construction such as the following in the mail merge main document:
{ = INT({=INT({=INT({ MERGEFIELD Number }/1000) }/100) }/100) },{ ={ =INT({ =INT({ MERGEFIELD Number }/1000) }/100) }-{ =({ =INT({ =INT({ =INT({ MERGEFIELD Number }/1000) }/100) }/100) }*100) } },{ ={ =INT({ MERGEFIELD Number }/1000) }-({ =INT({ =INT({
MERGEFIELD Number }/1000) }/100) }*100) },{ = { MERGEFIELD Number }-({ =INT({ MERGEFIELD Number }/1000) }*1000)}
where you use Ctrl+F9 to insert each pair of field delimiters { }
The above construction will format a number such as ######### (nine digits)
to ##,##,##,### or
######## (eight digits) to #,##,##,###
For 6 or 7 digit numbers, you would need to use
{ ={ =INT({ =INT({ MERGEFIELD Number }/1000)
}/100) }-{ =({ =INT({ =INT({ =INT({ MERGEFIELD Number }/1000) }/100) }/100)
}*100) } },{ ={ =INT({ MERGEFIELD Number }/1000) }-({ =INT({ =INT({ MERGEFIELD
Number }/1000) }/100) }*100) },{ = { MERGEFIELD Number }-({ =INT({ MERGEFIELD
Number }/1000) }*1000)}
and for 4 or 5 digit numbers, you would need to use
{ ={ =INT({ MERGEFIELD Number }/1000) }-({ =INT({ =INT({ MERGEFIELD Number }/1000) }/100) }*100) },{ = { MERGEFIELD Number }-({ =INT({ MERGEFIELD Number }/1000) }*1000)}
If the field contains numbers of different lengths, you would need to use the appropriate number of If...then...Else fields to check for the size of the number (>999, >99999, >9999999) and apply the appropriate field construction to get the desired
result.