Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2023, 06:09 AM
mason1100 mason1100 is offline Format a merge field with 22 digits Windows 11 Format a merge field with 22 digits Office 2016
Novice
Format a merge field with 22 digits
 
Join Date: Mar 2023
Posts: 3
mason1100 is on a distinguished road
Default Format a merge field with 22 digits

Hello,



I am having trouble with formatting a merge field with 22 digits. It is a tracking number and it should show as such:

0000 0000 0000 0000 0000 00

I understand that the \# "0000 0000 0000 0000 0000 00" will not work due to the merge field containing over 15 digits... Is there someone who could assist with a field construction for this merge field format?

Thanks in advance!
Reply With Quote
  #2  
Old 03-27-2023, 08:54 PM
gmayor's Avatar
gmayor gmayor is offline Format a merge field with 22 digits Windows 10 Format a merge field with 22 digits Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Convert the formatted data to text (easily achieved in Excel) and there will be no need for a switch.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 03-28-2023, 05:12 AM
mason1100 mason1100 is offline Format a merge field with 22 digits Windows 11 Format a merge field with 22 digits Office 2016
Novice
Format a merge field with 22 digits
 
Join Date: Mar 2023
Posts: 3
mason1100 is on a distinguished road
Default

How would I achieve this in Word? That is where we are running the mail merge.
Reply With Quote
  #4  
Old 03-28-2023, 10:16 PM
gmayor's Avatar
gmayor gmayor is offline Format a merge field with 22 digits Windows 10 Format a merge field with 22 digits Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You cannot do this in Word. You need to fix it in the data source. The most common data source for merge is Excel, hence my suggestion.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 03-29-2023, 05:11 AM
mason1100 mason1100 is offline Format a merge field with 22 digits Windows 11 Format a merge field with 22 digits Office 2016
Novice
Format a merge field with 22 digits
 
Join Date: Mar 2023
Posts: 3
mason1100 is on a distinguished road
Default

Thanks for the information!
Reply With Quote
  #6  
Old 04-01-2023, 09:20 PM
gmayor's Avatar
gmayor gmayor is offline Format a merge field with 22 digits Windows 10 Format a merge field with 22 digits Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I have had a thought about this. If you use Merge and Split or E-Mail Merge Add-in to create the merge, you could run a macro from the process to address the formatting e.g.
Code:
Sub FixID(oDoc As Document)
Dim oRng As Range
Const strFormat As String = "0000 0000 0000 0000 0000 00"
    Set oRng = oDoc.Range
    With oRng.Find
        Do While .Execute(findText:="<[0-9]{22}>", MatchWildcards:=True)
            oRng.Text = Format(oRng.Text, strFormat)
        Loop
    End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
mailmerge, mergefield, switches

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail merge field mistakenly interpret text format as date format alan6690 Mail Merge 0 09-02-2020 01:54 AM
Format a merge field with 22 digits Merge field return last 4 digits of a number macquhele Mail Merge 6 08-01-2020 11:04 PM
Format a merge field with 22 digits 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 a merge field with 22 digits Custom format a merge field paul h Mail Merge 2 09-09-2015 07:18 AM
Format a merge field with 22 digits Mail merge will not format date field generated by Excel IF statement borntorun75 Mail Merge 3 12-16-2011 06:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:27 AM.


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