Alec
Lanticans
    Offline
Posts: 200
Location: Ascot, England, UK
Joined: Nov 22 nd, 2002
|
Using MS-Word switches to format merge fields
Feb 3rd, 2004 at 8:08pm
|
Print Post
|
There have been a number of postings from folk having trouble with database values being printed in Microsoft Word documents 'unformatted'. That is, with extra decimal places or dates in YYYY/MM/DD format. A number of solutions have been offered.
The solution, though, lies outside of Sesame. It's to use Word's field switches.
Firstly, in your merge document, show the field code rather than the result. To do this click on the field and press Shift F9, or press Alt F9 to toggle all field codes.
Click at the end of the field code and add the appropriate switch. For example, change ..
{MERGEFIELD Date} to {MERGEFIELD Date \@ "MMMM dd, yy"}
Where "Date" is the column heading ("field name") of the field in question. The field code starts with the \ character.
By this means you can vary the number of decimal places for numbers, format dates any way you want, and turn numbers into currency amounts. Here are some examples...
Dates
\@ "MM/dd/yyyy" produces 11/19/2003 \@ "MM-dd-yy" produces 11-19-03 \@ "dd MMM yy" produces 19 Nov 03 \@ "dddd, MMMM d, yyyy" produces Wednesday, November 19, 2003
Numbers & Currency Example = 1237.852941
\#0.00 produces 1237.85 \#0 produces 38 \#$#,###.00 produces $ 1,237.85 \#£#,### produces £ 1,238
Text
\* Upper produces NY from "ny" \* Caps produces New York from "new york"
Once you've set the field code, press Shift F9 to display the value again. Don't be alarmed - it will still show the previous formatting. Press F9 to 'refresh' the field.
This is described in the Programming Guide pages 242-243.
|