![]() |
|
#1
|
||||
|
||||
![]()
You've posted this question as a mailmerge topic, but your field code refers to a REF field, not a mailmerge field.
Word cannot format numeric values having more than 15 significant digits. With some field math, though, you could use a field code to evaluate the number's order of magnitude and prefix the mergefield's unformatted output with the required number of 0s. Assuming you're using a mailmerge, if your source data contains the leading 0s (and is not just formatted to display leading 0s), a simple approach would be to create a dummy first record with some random text in that field. That way, the mailmerge will treat the data as text and output it with the leading 0s. Otherwise, you can use some field math in another field to determine the data field's order of magnitude and, from that, the number of leading 0s to output. For example, using an ASK field to demonstrate the process: Code:
{QUOTE↵ {ASK a "Input the raw number"}↵ {=a<10^17 \# "'0';;"}{=a<10^16 \# "'0';;"}{=a<10^15 \# "'0';;"}{=a<10^14 \# "'0';;"}{=a<10^13 \# "'0';;"}{=a<10^12 \# "'0';;"}{=a<10^11 \# "'0';;"}{=a<10^10 \# "'0';;"}{=a<10^9 \# "'0';;"}{=a<10^8 \# "'0';;"}{=a<10^7 \# "'0';;"}{=a<10^6 \# "'0';;"}{=a<10^5 \# "'0';;"}{=a<10^4 \# "'0';;"}{=a<10^3 \# "'0';;"}{=a<10^2 \# "'0';;"}{=a<10^1 \# "'0';;"}}{REF a} For a macro to convert the above field code representation into a working field code, see Convert Text Representations of Fields to Working Fields in the Mailmerge Tips and Tricks 'Sticky' thread at the top of this forum: https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#2
|
|||
|
|||
![]()
Paul, a big sincere THANK YOU for your help! That did the trick and the number is appearing with leading zeroes, no matter the original amount of digits. Your assistance was clutch.
![]() |
![]() |
Tags |
field code, numeric picture switch |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Paste in picture, wrap with line, format paragraph before and picture...close to working | ctviggen | Word VBA | 3 | 03-25-2023 08:49 AM |
IF statement for numeric picture switch | jocotan88 | Mail Merge | 1 | 06-30-2021 06:40 PM |
![]() |
becca | Mail Merge | 2 | 06-08-2016 01:15 PM |
Format Switch \* Caps won't work in if..then statement | cwright | Word | 2 | 03-27-2014 04:19 PM |
![]() |
sbarron76 | Mail Merge | 3 | 05-03-2013 06:23 AM |