Word Mail Merge Format Switches

marka87uk

Board Regular
Joined
Mar 24, 2007
Messages
247
Hi,

I have a Word mail-merge linked to an Excel document. The Excel file is outputted automatically from a program so I would rather not apply any formatting in the spreadsheet itself.

I'd like to display the following fields as below. Please can you advise me on how to do this?

Phone number - 00000 000000 (they may appear as a number or text in the Excel file)
NI number - AA-00-00-00-A

Also dates are appearing in American format even though they appear correctly in the Excel file - How can I change this?

Thanks! :)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Thanks Trevor,

I still can't seem to get the switches right for the phone number and NI number fields.

The phone number displays correctly using \# "00000 000000" when the data is a straight number in Excel, but if it is already entered with the space (and treated as text), it causes it to be a totally different number! Is there a way to do this without formatting in Excel?

For the NI number I have had no luck as it's a text field.
 
Upvote 0
Sorry, and the Microsoft link didn't help too much... I have tried { MERGEFIELD "date_joined" \@ "dd/mm/yyyy" } but the dates do not appear correctly.
 
Upvote 0
Just back at PC, pleased to read you have a solution. ;)
 
Upvote 0
The phone number displays correctly using \# "00000 000000" when the data is a straight number in Excel, but if it is already entered with the space (and treated as text), it causes it to be a totally different number! Is there a way to do this without formatting in Excel?
For this one, you can use a field coded along the lines of:
{QUOTE{SET Val{MERGEFIELD Phone_No}}{IF{REF Val}= {=Val \# 00000000000} {=Val \# "000000' '00000"} {REF Val}}}
For the NI number I have had no luck as it's a text field.
What do you see when you merge this field with no switches?
 
Upvote 0
For this one, you can use a field coded along the lines of:
{QUOTE{SET Val{MERGEFIELD Phone_No}}{IF{REF Val}= {=Val \# 00000000000} {=Val \# "000000' '00000"} {REF Val}}}

What do you see when you merge this field with no switches?

====
Old thread, I know. Can someone please explain to this VBA programmer what this gibberish means?

Thank you.
 
Upvote 0
Can someone please explain to this VBA programmer what this gibberish means?
Well, it's not gibberish and it's not VBA - it's a Word field code that tests whether a string is the same as a numerical evaluation of the string and, depending on the results, outputs either the original string or a formatted version of it.
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top