Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-23-2013, 07:59 PM
hadenp hadenp is offline Right Justify Values in a Mail Merge Windows XP Right Justify Values in a Mail Merge Office 2010 32bit
Novice
Right Justify Values in a Mail Merge
 
Join Date: Dec 2013
Posts: 4
hadenp is on a distinguished road
Default Right Justify Values in a Mail Merge


I'm working up a Word mail merge "Thank you" letter for a non-profit that lists the dates and amounts given for each donor during the year for tax deduction purposes.

For this, I've relied heavily on the Word Catalogue Mailmerge tutorial and after great difficulty understanding it, I'm now beginning to 'get it'. Thank you Paul!

So, now I can list the values, but how do I format them to look 'good' on the page? For me, that means right justifying the $ amounts under the "Amount" heading. Is that best done with tabs? How do I specify that within the field code syntax that I'm using to generate the list? Also, how to underline the heading text? The output would ideally look something like this - only better.

Date………......Amount
Feb/01/2013 $225.00
Mar/01/2013 $10.00
Apr/01/2013 $50.00
------------------------------
Total $285.00

Finally, I'd like to have Total line at the bottom with a sum of the amounts. Is that best calculated as a formula the Excel spreadsheet? How would I underline the last amount

Thanks again for the tutorial.
Reply With Quote
  #2  
Old 12-23-2013, 09:35 PM
macropod's Avatar
macropod macropod is offline Right Justify Values in a Mail Merge Windows 7 32bit Right Justify Values in a Mail Merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by hadenp View Post
I can list the values, but how do I format them to look 'good' on the page? For me, that means right justifying the $ amounts under the "Amount" heading. Is that best done with tabs? How do I specify that within the field code syntax that I'm using to generate the list?
A single right-aligned tab-stop in the field code and a corresponding tab character between the relevant fields will suffice.
Quote:
Also, how to underline the heading text? The output would ideally look something like this - only better.

Date………......Amount
Feb/01/2013 $225.00
Mar/01/2013 $10.00
Apr/01/2013 $50.00
------------------------------
Total $285.00
Just as the tutorial demonstrates headings with bold text, you can apply an underline format at the same point.
Quote:
Finally, I'd like to have Total line at the bottom with a sum of the amounts. Is that best calculated as a formula the Excel spreadsheet? How would I underline the last amount
For the total line, the tutorial provides two options, described in the tutorial's 'Using an Extra Field to Generate the Trailing Content Per Group' or 'Calculating Group and Sub-Group Totals' examples, respectively. Note that using an underline for the last record with either of these will necessitate a suitably-formatted line to be inserted just above the code that actually outputs the total, not in the other data lines.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-25-2013, 12:03 AM
hadenp hadenp is offline Right Justify Values in a Mail Merge Windows XP Right Justify Values in a Mail Merge Office 2010 32bit
Novice
Right Justify Values in a Mail Merge
 
Join Date: Dec 2013
Posts: 4
hadenp is on a distinguished road
Default

Thanks for your responses to my questions Paul, but I'm still unclear on how to achieve what I'm trying to do...

Re: the justification question- Do I need to insert braces and then use Word's insert tabs dialog to insert the tab stop and tab? What value would I put in the Tab Stop position? That's what I tried and got partial results but two of the currency fields were pushed further to the right, perhaps because the month abbreviations for 'Mar' and 'May' take up slightly more space than 'Feb'?

Re: inserting a Totals line - I just need totals for one group (Amounts) per key. I inserted
Quote:
{Set Tot1 0 }
immediately after the {Set Key) statement in the first line of code. Then, I output Tot1 just after
Quote:
{IF {MERGESEQ} >1 "
.

Further down, where I output date and amount records, I inserted
Quote:
{Set Tot1 {=Tot1+{MERGEFIELD Amount}}}
, which if I understand correctly is where each amount is being summed into Tot1. However, the Total shows as 0. :{

My understanding of the syntax is still rudimentary and I think I must be missing something. Thanks in advance for any suggestions.
Reply With Quote
  #4  
Old 12-25-2013, 12:37 AM
macropod's Avatar
macropod macropod is offline Right Justify Values in a Mail Merge Windows 7 32bit Right Justify Values in a Mail Merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by hadenp View Post
Re: the justification question- Do I need to insert braces and then use Word's insert tabs dialog to insert the tab stop and tab? What value would I put in the Tab Stop position?
No extra field braces are required. You need only insert the tab stops in the positions where you want the alignment to occur, just as you would in an ordinary document. Don't be concerned with whether they mergefields align correctly, as they're quite possibly going to be wider than the actual data.
Quote:
Re: inserting a Totals line - I just need totals for one group (Amounts) per key. I inserted immediately after the {Set Key) statement in the first line of code. Then, I output Tot1 just after .

Further down, where I output date and amount records, I inserted , which if I understand correctly is where each amount is being summed into Tot1. However, the Total shows as 0. :{

My understanding of the syntax is still rudimentary and I think I must be missing something. Thanks in advance for any suggestions.
For your purposes, you could use the two {SET Tot1 0} fields, the {SET Tot1 {=Tot1+{MERGEFIELD Sales}}} field (all in red), plus the {=Tot1 \# $,0} field (with or without the table, depending on what you're doing table-wise). Note that, because you now have two fields for the true condition in the initial IF test, they need to be wrapped in double-quotes, thus:
{IF{MERGESEQ}= 1 "{SET Key ""}{SET Tot1 0}" {SET LastKey {REF Key}}}
In the attachment, which is based directly on the tutorial, I've implemented the totals for a merge using a single key - using 'Total' instead of 'Tot1'. If you simply connect it to your copy of the tutorial's datasource file, you should be able to generate the merge.
Attached Files
File Type: doc Mailmerge Main Document.doc (33.5 KB, 33 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-26-2013, 08:13 PM
hadenp hadenp is offline Right Justify Values in a Mail Merge Windows XP Right Justify Values in a Mail Merge Office 2010 32bit
Novice
Right Justify Values in a Mail Merge
 
Join Date: Dec 2013
Posts: 4
hadenp is on a distinguished road
Default

I wasn't able to make my document give me totals correctly (kept getting a calculation error that would continue through my (small) recordset) - so I started again with your attachment and gradually introduced my own field names and structure and that worked like a charm. Thanks!

But, I don't have much confidence that I can make changes w/o 'breaking' it. For example, what determines when one needs to wrap code with double quotes? Is there any documentation you could refer me to so I can understand the syntax better? I assume that the opening and closing braces
have to be paired, but with nesting it quickly becomes difficult to tell if you're missing a brace. Any thoughts?

Thanks again for your help.
Reply With Quote
  #6  
Old 12-27-2013, 03:04 AM
macropod's Avatar
macropod macropod is offline Right Justify Values in a Mail Merge Windows 7 32bit Right Justify Values in a Mail Merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

The issue with the double quotes relates to the construction of the IF test. Essentially, if any part of the expression contains more than one field or word, that part of the expression needs to be enclosed in double quotes.

As for documentation, there is some available via the Insert|Quick Parts|Field dialogue, and some more at:
http://office.microsoft.com/en-us/wo...102110133.aspx?
http://office.microsoft.com/en-us/wo...101830917.aspx
If you want to learn more of what you can do with fields, check out the 'Sticky' threads (all of which I authored) at:
http://windowssecrets.com/forums/for...ord-Processing
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 12-29-2013, 01:37 PM
hadenp hadenp is offline Right Justify Values in a Mail Merge Windows XP Right Justify Values in a Mail Merge Office 2010 32bit
Novice
Right Justify Values in a Mail Merge
 
Join Date: Dec 2013
Posts: 4
hadenp is on a distinguished road
Default

Thanks Paul. Would you be able to explicate how quotes are paired in a code example from the Mailmerge Tutorial for us ?

In the first example, "Merge Records by Category",

{QUOTE{IF {MERGESEQ} =1 {SET KEY ""}}"{IF{MERGEFIELD City}<> {REF Key}
"IF...

is the quote (in red) the beginning of a new expression? And does that expression end with the next quote before IF - or is it paired with another quote further down?

Also, the use of QUOTE..I think it's used here to return values after expressions are evaluated. Is that correct?

Thanks!
Reply With Quote
  #8  
Old 12-31-2013, 07:40 PM
macropod's Avatar
macropod macropod is offline Right Justify Values in a Mail Merge Windows 7 32bit Right Justify Values in a Mail Merge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

I'm not sure which of the subsequent IF fields is indicated after the second red double-quote in your post. There are multiple IF statements and double-quotes used in that set of fields.

The best way to see which expressions are bound by a common field is to select the opening brace, then extend the selection forward by one character. That should cause the actual selection to expand to encompass the whole of that field and any others nested within it.

As for the external QUOTE field, that's really nothing more than a container for the rest of the construction - the coding would work equally well without it. Having it, though, makes copying & pasting a given set of fields far easier. As a rule, QUOTE fields also require the use of double quotes to bound the expressions they're to output. However, you can also use unbounded numeric expressions to create some interesting effects, such as the generation of page breaks - as done in the code example I posted; there's another example in the last paragraph in the tutorial itself.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
field code, justification, tabs



Similar Threads
Thread Thread Starter Forum Replies Last Post
Loss of formulae values when mail merging excel to word MellowMel Mail Merge 6 05-09-2014 09:08 AM
Prevent Zero Values being Suppressed in a Mail Merge HangMan Mail Merge 2 12-11-2013 02:28 PM
Right Justify Values in a Mail Merge Content control merge values? skrallemand Word VBA 8 10-02-2013 06:54 AM
Mail Merge Duplication of address on merge RICKY Mail Merge 1 09-26-2012 03:14 PM
Right Justify Values in a Mail Merge Conditional merge fields in mail merge Aude Mail Merge 1 01-06-2012 07:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:15 PM.


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