Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2024, 10:17 AM
tagyoureit tagyoureit is offline Unable to format numeric picture switch properly Windows 11 Unable to format numeric picture switch properly Office 2021
Novice
Unable to format numeric picture switch properly
 
Join Date: Aug 2024
Posts: 2
tagyoureit is on a distinguished road
Post Unable to format numeric picture switch properly

I'm trying to format a numeric merge field in Microsoft Word 365. I normally use a numeric picture switch like this:



\# 000000000000000000
This is what the full field code looks like:

{ REF bookmark \# 000000000000000000 \* MERGEFORMAT }
That's 18 total zeroes. I need to be able to have up to 18 digits showing with leading zeroes. If the referenced bookmark has 3 digits, I need 15 leading zeroes. If the bookmark has 15 digits, I need 3 leading zeroes. The length can be varied but always numbers. (There are no commas or dollar signs in the field.)


When I use the switch mentioned above, the number is rounded off after 14 digits. If my number is 1234567890123456, the number that appears is 001234567890123500. If I don't include the numeric picture switch and just use the ref field, the numbers aren't rounded off but also the leading zeroes don't appear. If possible, I need the switch to remain so I can keep those leading zeroes.


Any help will be greatly appreciated!!
Reply With Quote
  #2  
Old 08-19-2024, 04:06 PM
macropod's Avatar
macropod macropod is offline Unable to format numeric picture switch properly Windows 10 Unable to format numeric picture switch properly Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,382
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required. Instead of the ↵ symbols, you should use real line breaks.

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]
Reply With Quote
  #3  
Old 09-19-2024, 09:31 AM
tagyoureit tagyoureit is offline Unable to format numeric picture switch properly Windows 11 Unable to format numeric picture switch properly Office 2021
Novice
Unable to format numeric picture switch properly
 
Join Date: Aug 2024
Posts: 2
tagyoureit is on a distinguished road
Default Thank you!

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.
Reply With Quote
Reply

Tags
field code, numeric picture switch



Similar Threads
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
Unable to format numeric picture switch properly how to format a picture switch in a merge field to only include the numbers in the middle? 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
Unable to format numeric picture switch properly Date format switch with If statement sbarron76 Mail Merge 3 05-03-2013 06:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft