Consulting

Results 1 to 5 of 5

Thread: Spaces produced when mergefiled contains no data

  1. #1

    Spaces produced when mergefiled contains no data

    Offce 2000. Data source = Excel. Mailmerge in Word. Example:
    <Title> <First_Name> <Last_name> If individual has no title, the first line is indented one space.

    Similar problem in creating directory. Following code on one line.
    <Street1> <Street2>, <City>, <ST> <Zip> .... when there is no Street2 then the printout results in a space after Street1 then the comma and another space before ST. This is easy to clean up in the merged document using search/replace, but the one space indent decribed above has to be changed one at a time.

    Have searched knowledge base and answer seems to be that there is no problem if the empty mergefield is followed by a Paragrah Mark or on a line with no other data. As this is not possible, is their any other way to deal with the blank spaces inserted by an empty mergefield?<img>

    Thank you.
    Trudy

  2. #2
    VBAX Expert TrippyTom's Avatar
    Joined
    Jul 2005
    Location
    New York, NY (USA)
    Posts
    556
    Location
    A workaround would be to put a space at the end of those cells that DO have something in them, then mesh them all together with no spaces in the merge fields. That way, if there is a cell with no name, no space will be created.

    Perhaps not the best solution, but it would solve it for now until someone comes up with a better idea.

  3. #3
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    { MERGEFIELD Street1 }{IF {MERGEFIELD Street2 }<> "" " {MERGEFIELD Street2 }" "" }, { MERGEFIELD City }, { MERGEFIELD ST } {MERGEFIELD Zip }
    Last edited by geekgirlau; 12-01-2005 at 05:17 PM. Reason: Format went strange!

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Trudy,
    You could insert a space using an If..Then..Else field. If Data1 is not blank {space}

    {IF {data1}<> "" " " "" }

    I think Tom's solution is simpler though.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Quote Originally Posted by geekgirlau
    { MERGEFIELD Street1 }{IF {MERGEFIELD Street2 }<> "" " {MERGEFIELD Street2 }" "" }, { MERGEFIELD City }, { MERGEFIELD ST } {MERGEFIELD Zip }
    ... and
    Quote Originally Posted by mdmackillop
    Hi Trudy,
    You could insert a space using an If..Then..Else field. If Data1 is not blank {space} {IF {data1}<> "" " " "" }
    <img><img>

    Thank you all for the suggestions. I had thought this must be such a common problem that it was going to be one of those things covered in the knowledge base. Clearly, that is not the case, so I really appreciate the ideas. I had already tried adding a space in the Excel field, but it didn't remain in the merged data.

    I am particularly interested in trying the code for the missing title, as that is most annoying when doing form letters and envelopes. Meanwhile, for the label merge I recorded a macro to do a find/replace to clear all the "space, comma" occurences and to also do a find/replace for the missing title one space indent annoyance.. For the letters and envelopes, I'm hoping the code will work so they can be sent directly to the printer as it is set up.

    I have received so much valuable help from this site and the wonderful people who are willing to give time to help newbies like me. I cannot return the favor, so I want you to know I am volunteering to go to homes of very elderly individuals for whom we are scrounging old computers and trying to set them up very simply so they can communicate with family and friends via email. I get lots of call for HELP, as most have never tried to control a mouse, etc. It is a lot of fun. So thanks for helping me learn to do what our church secretary did before she died (I had never seen an Excel worksheet or written formulas or code - still mostly in the dark about that<img> - or done a merge). Thanks again!<img> Trudy

Posting Permissions

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