Results 1 to 6 of 6

Thread: Merge Fields

  1. #1
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Merge Fields

    Without going into details, I can't use the default greeting line and/or address block merge fields. As a result, I'm left with building my own. I'm trying to add a greeting, but I get the following results:

    <<fname>> <<lname>>
    <<address1>>
    <<address2>>
    <<city>>, <<state>> <<zip>>

    TestUser
    100 Test Street

    Herndon, VA 22222

    Is there any way to collapse the space if there is no address 2 and also build in the spacing for commas in the merge fields?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    This is a very rough description, but...

    You can avoid inserting blank lines when a merge field is blank by using IF fields and a little trick regarding line breaks.

    Code:
    { IF { MERGEFIELD address2 } = "" "" "{ MERGEFIELD address2 }
    " }{ MERGEFIELD city }, { MERGEFIELD state } { MERGEFIELD zip }
    As you can see, rather than place the enter that follows the address2 field between the merge fields, you place it inside the IF tag. That way, the line break only is inserted if address2 is not blank.

    At least, that's the theory. I hardly ever do merges. Does it work?

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    A simpler way is to add a control switch to the mergefields:
    {Mergefield fname \f " "}{Mergefield lname}
    {Mergefield Address1\f "
    "}
    {Mergefield Address2 \f "
    "}
    {Mergefield City}, {Mergefield State} {Mergefield Zip}

    In the above coding, I've allowed for either/both address fields to be empty. The symbols should be replaced with genuine paragraph or line breaks.

    For more info on mergefield-specific switches, see: http://office.microsoft.com/en-us/wo...005186172.aspx
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #4
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the quick response! I tried the following but am still running into issues with spacing between the address 2 field and city, state, zip line. For example:

    Joe Smith
    PO Box 1
    Dept. 1

    Herndon , VA 11111

    It should be like this:
    Joe Smith
    PO Box 1
    Dept. 1
    Herndon, VA 11111

    Notice the comma placement is off in the first example as well. Here is a screenshot:

    screenshot.png

    Additionally, I have a currency field that returns balance:

    { MERGEFIELD "Balance" \# $##,###.00 }

    If there is a $0 balance, the following is returned: $.00. Is it possible to format as $0.00? Any insight is MUCH appreciated! Thank you in advance!

  5. #5
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Almost

    I was able to correct the dollar amount but am still banging my head against the wall when it comes to the address block. I can't seem to get rid of the blank lines if Address, Address1, or Address2 is blank. Any insight would be GREATLY appreciated!

    screenshot.png

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi bkirkby,

    There was a bit of mis-direction in my previous post.

    Taking account of what it appears you want to do the with City & State fields, I believe either of the following will meet your needs:
    {Mergefield fname \f " "}{Mergefield lname}
    {Mergefield Address}
    {Mergefield Address1 \f "
    "}{Mergefield Address2 \f "
    "}{Mergefield City \f ", "}{Mergefield State \f " "}{Mergefield Zip}
    or:
    {Mergefield fname \f " "}{Mergefield lname}
    {Mergefield Address}{Mergefield Address1 \b "
    "}{Mergefield Address2 \b "
    "}
    {Mergefield City \f ", "}{Mergefield State \f " "}{Mergefield Zip}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •