• Word inserts space when field is blank in merge

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Word inserts space when field is blank in merge

    Author
    Topic
    #462538

    I am using data from a table to merge into a Word document directory format. When I do the merge, Word inserts a space wherever there is no data in a field. Can you please tell me how to get rid of the space? It ends up looking like this:

    Sequoia Healthcare District
    Hon. Mary Smith
    Hon. Jim Time
    Hon. Twit Pick
    Joe Jones

    (Since there was no title for Joe Jones, it puts a space before Joe but you can’t see it because when I preview this, your system removes the space)

    Thank you so much for your help.

    Viewing 1 reply thread
    Author
    Replies
    • #1177583

      Not sure what version of Word you are using but only because I discovered this while trying to make some mail merge labels [post=”793367″]Post 793367[/post] the same thing happens with my data base and I found out it could be to do with “Styles” you would think the “normal” style wouldn’t have spaces, but not so….I have to select the style “no space” and that does the trick for me in getting rid of the blank lines, see here and scroll right the way down the article, dont know if this will help….meanwhile I struggle on with inserting a picture

      from the link:
      Note:
      Microsoft appears to have retained the default use of the ‘normal’ paragraph style to format tables; however, in Word 2007, the normal paragraph style has added spacing. This will result in extra spacing between the lines of text in tables. Word uses tables to create labels; however when those labels are created using the label tool the process is supposed to remove that extra spacing. In practice I find that it is not 100% reliable, but that is what is supposed to happen.

      The default style set also includes a standard ‘No spacing’ style which is what long standing Word users would have expected to have been the Normal style. Why Microsoft swapped these styles around I cannot say, but …..

      You can edit the Normal paragraph style to remove that spacing, just as you can edit any other style, and this will fix the issue for labels you create from the label tool (I would also rename the No Spacing style to Normal Spaced and add to it the spacing you have removed from the normal style); however ……

      Even more complicating is the fact that when mail merging labels, although the Normal style is used, extra padding is inserted as direct formatting, by the merge process, before each paragraph. This conspires to screw up the spacing of the paragraphs on your merged labels (see the right hand illustration immediately below this note).

      You must take this into consideration when adding merge fields and apply whatever formatting you need to give the presentation you require. One method would be to apply a non-spaced style to the first label before updating the labels. If you have modified the Normal style as mentioned above, you can simply re-apply that Normal style, which has the effect of removing the padding.

      The bottom line here is that if your labels have unwanted space, correction is a question of applying the correct formatting.

      • #1177646

        Not sure what version of Word you are using but only because I discovered this while trying to make some mail merge labels [post=”793367″]Post 793367[/post] the same thing happens with my data base and I found out it could be to do with “Styles” you would think the “normal” style wouldn’t have spaces, but not so….I have to select the style “no space” and that does the trick for me in getting rid of the blank lines, see here and scroll right the way down the article, dont know if this will help….meanwhile I struggle on with inserting a picture

        from the link:
        Note:
        Microsoft appears to have retained the default use of the ‘normal’ paragraph style to format tables; however, in Word 2007, the normal paragraph style has added spacing. This will result in extra spacing between the lines of text in tables. Word uses tables to create labels; however when those labels are created using the label tool the process is supposed to remove that extra spacing. In practice I find that it is not 100% reliable, but that is what is supposed to happen.

        The default style set also includes a standard ‘No spacing’ style which is what long standing Word users would have expected to have been the Normal style. Why Microsoft swapped these styles around I cannot say, but …..

        You can edit the Normal paragraph style to remove that spacing, just as you can edit any other style, and this will fix the issue for labels you create from the label tool (I would also rename the No Spacing style to Normal Spaced and add to it the spacing you have removed from the normal style); however ……

        Even more complicating is the fact that when mail merging labels, although the Normal style is used, extra padding is inserted as direct formatting, by the merge process, before each paragraph. This conspires to screw up the spacing of the paragraphs on your merged labels (see the right hand illustration immediately below this note).

        You must take this into consideration when adding merge fields and apply whatever formatting you need to give the presentation you require. One method would be to apply a non-spaced style to the first label before updating the labels. If you have modified the Normal style as mentioned above, you can simply re-apply that Normal style, which has the effect of removing the padding.

        The bottom line here is that if your labels have unwanted space, correction is a question of applying the correct formatting.

        Thank you for your help. I tried changing the style to no spacing but it didn’t work. However, since I haven’t used styles, I probably didn’t do it correctly. Here’s what I did: I started my merge, chose directory and selected new document. Then I went to the styles ribbon and under the Change Styles button there is a two sided arrow to “show styles window” From that window I selected “no spacing.” I didn’t change any options under “no spacing” because I don’t know if I need to. The option button is selected for “only in this document.” Then I completed the merge with my fields. I still get the space so I must be doing something wrong.

        Please note: I don’t want to get rid of any extra lines. It’s the space that it inserts as the first character of a new line.
        I couldn’t show it in my original post but if you look at it again, the last line where the person doesn’t have an “Hon.” in front of his name, inserts a space where a title would go if he had one in that field. It doesn’t show in my example because I couldn’t get this system to allow me to type a space – it deletes it when it posts.

        Hope you can help! Thanks.

    • #1177627

      I am using data from a table to merge into a Word document directory format. When I do the merge, Word inserts a space wherever there is no data in a field.

      (Since there was no title for Joe Jones, it puts a space before Joe but you can’t see it because when I preview this, your system removes the space)

      Second point first, you can preserve spacing by using [b]code[/b][b]/code[/b] around the text in that part of your post. (You can go back and do it now if you like, or keep this for future reference.)

      Word’s merge feature allows you to use a variety of additional fields to test certain conditions, such as the {IF} field. To create an IF field, you can press Ctrl+F9 and type IF, and then copy and paste in your merge field as needed. For example, to avoid a blank space “between” a missing field and a field that is present, you can wrap it in an IF field as follows (note: air code, not from a working solution, change the merge field names to their real names):

      Code:
      {IF{TITLE}"" "{TITLE} " ""}{FIRSTNAME} {LASTNAME}

      In English, that’s “if the TITLE is not blank, insert the title followed by a space, otherwise insert nothing.” Does that help?

      • #1177633

        Second point first, you can preserve spacing by using [b]code[/b][b]/code[/b] around the text in that part of your post. (You can go back and do it now if you like, or keep this for future reference.)

        Word’s merge feature allows you to use a variety of additional fields to test certain conditions, such as the {IF} field. To create an IF field, you can press Ctrl+F9 and type IF, and then copy and paste in your merge field as needed. For example, to avoid a blank space “between” a missing field and a field that is present, you can wrap it in an IF field as follows (note: air code, not from a working solution, change the merge field names to their real names):

        Code:
        {IF{TITLE}"" "{TITLE} " ""}{FIRSTNAME} {LASTNAME}

        In English, that’s “if the TITLE is not blank, insert the title followed by a space, otherwise insert nothing.” Does that help?

        Thank you! I will try using the code.

        I did try using the other code to add a space to my post but you can see what I got. I’m sure I didn’t do it correctly – what am I missing?

        • #1177638

          Second point first, you can preserve spacing by using [b]code[/b][b]/code[/b] around the text in that part of your post.

          I did try using the other code to add a space to my post but you can see what I got. I’m sure I didn’t do it correctly – what am I missing?[/quote]
          Hmmm, it used to work on the old board software. Maybe it’s not supported on this version? Hopefully we can find another way, or people will have to post images to show what they mean.

      • #1177642

        Second point first, you can preserve spacing by using [b]code[/b][b]/code[/b] around the text in that part of your post. (You can go back and do it now if you like, or keep this for future reference.)

        Word’s merge feature allows you to use a variety of additional fields to test certain conditions, such as the {IF} field. To create an IF field, you can press Ctrl+F9 and type IF, and then copy and paste in your merge field as needed. For example, to avoid a blank space “between” a missing field and a field that is present, you can wrap it in an IF field as follows (note: air code, not from a working solution, change the merge field names to their real names):

        Code:
        {IF{TITLE}"" "{TITLE} " ""}{FIRSTNAME} {LASTNAME}

        In English, that’s “if the TITLE is not blank, insert the title followed by a space, otherwise insert nothing.” Does that help?

        I tried using the above code and this is what I’m getting:
        Congressional Delegation

        Code:
        {IF{TITLE}"" "{TITLE} " ""}
        Code:
        {IF{TITLE}"" "{TITLE} " ""}

        Anna Eshoo

        Code:
        {IF{TITLE}"" "{TITLE} " ""}

        Jackie Speier

        Code:
        {IF{TITLE}"" "{TITLE} " ""}

        Assembly

        Code:
        {IF{TITLE}"" "{TITLE} " ""}
        Code:
        {IF{TITLE}"" "{TITLE} " ""}

        Jerry Hill

        Code:
        {IF{TITLE}"" "{TITLE} " ""}

        Fiona Ma

        here is what I’m typing:

        «Category»

        Code:
        {IF{TITLE}"" "{TITLE} " ""}

        «FNAME» «LNAME» «POSITION» «PLACE»

        I’ve never done this code stuff before so I’m probably not doing it correctly (yikes!) You’re very patient – thanks!

        • #1177650

          I tried using the above code and this is what I’m getting:

          I’m sorry, I used {NAME} where I should have used «NAME». I don’t do merges very often. Maybe two or three times per decade.

          == Edit ==

          It may be beneficial to copy and paste the relevant part from your main merge document into a clean document and upload that here (attach it to a new reply) for review.

          • #1177653

            I’m sorry, I used {NAME} where I should have used «NAME». I don’t do merges very often. Maybe two or three times per decade.

            == Edit ==

            It may be beneficial to copy and paste the relevant part from your main merge document into a clean document and upload that here (attach it to a new reply) for review.

            Thanks! I am attaching a part of the Table (Table.docx) that I am using to merge it into a new document as well as a portion of the merged document (merged.docx). I’m not really merging the data with anything. I’m just using the merge feature so that I can have a document that looks like the one I have attached. After I complete the merge, I have to go in and fix all the formatting – it doesn’t come out this way. I added the bold, italics and line spaces between sections, and columns. I don’t think there is any other way of getting the information from the table into this format without using merge.

            • #1177666

              Thanks! I am attaching a part of the Table (Table.docx) that I am using to merge it into a new document as well as a portion of the merged document (merged.docx).

              Actually, the critical part is the other document, the one with the merge fields, before you merge it.

            • #1177673

              Actually, the critical part is the other document, the one with the merge fields, before you merge it.

              ok, here it is (merge codes.docx)

              Elaine

            • #1177674

              Actually, the critical part is the other document, the one with the merge fields, before you merge it.

              Also, FYI, here are the steps I take for the merge:

              Start with new blank document
              On the mailings tab, select Start Mail Merge, Step by Step
              Choose document type = directory
              Click next: starting document
              Use current document
              Click next: select recipients
              Select use an existing list >Browse> select file (table) > open
              Select all records (ok)
              Next
              Choose: More items
              Select the fields per document “merge codes.docx”
              Preview
              Complete the merge to document

              It comes out without the formatting, but I add that.

              Thanks,
              Elaine

            • #1177709

              You have to set up your table differently – the category has to be repeated for each row, and the table needs to have column headings.
              To merge, you need a Directory type merge, as explained in macropod’s Word 97-2007 Mailmerge Tutorial: Create Sorted Listings (v1.52).

              I have attached a zip file with the modified merge document and table. Remember that you must set the merge type to Directory for it to work correctly. And you must merge to a new document to see the result.

            • #1177711

              You have to set up your table differently – the category has to be repeated for each row, and the table needs to have column headings.
              To merge, you need a Directory type merge, as explained in macropod’s Word 97-2007 Mailmerge Tutorial: Create Sorted Listings (v1.52).

              I have attached a zip file with the modified merge document and table. Remember that you must set the merge type to Directory for it to work correctly. And you must merge to a new document to see the result.

              Hi Hanz, thank you for your help. I opened the attachments but the Merge_Codes document didn’t have any codes in it. It just said “coastside water district.” I’m anxious to see how it comes out because I don’t want the category to repeat in my final document. I have been using the Directory type merge and everything merges just fine. However, I get that extra space that I can’t get rid of. It doesn’t line up to the left margin.

              Could you resend the merge_codes document with the codes you used so I can try merging your documents? Thanks.

              Elaine

            • #1177712

              The merge document does contain fields, but you have to view field codes to see them – press Alt+F9 to toggle field codes on and off.

              I have attached the result of the mail merge as an example.

            • #1177713

              The merge document does contain fields, but you have to view field codes to see them – press Alt+F9 to toggle field codes on and off.

              I have attached the result of the mail merge as an example.

              Thank you, Hanz. I will work on this later this afternoon as I have a class to attend now. I really appreciate your help!

            • #1177772

              Thank you, Hanz. I will work on this later this afternoon as I have a class to attend now. I really appreciate your help!

              Hello again, Hanz. You must be a very patient man to help people like me!! Again, I sincerely appreciate it.

              So, I fixed my table so that the category field is filled in for each record. Then I did the merge using your codes. It came out sort of ok but here are my issues that I hope you can help me fix:

              There are some records that didn’t show up. Example: congressional delegation has two people in it but they didn’t show up on the merged list, Pacifica and Portola Valley are also empty but there are people in the Table. I can’t figure out why they aren’t showing up. Additionally there are lots of spaces between the categories that I’m not sure where in the code the spaces are.

              I need an extra space after each grouping but I don’t want a space between the group name and the first person. Ex:

              Congressional Delegation
              Hon. Anna Eshoo
              Hon. Jackie Speier

              I am attaching the merged document as well as the codes document so you can see what I mean.

              Again, many thanks for your help.

              p.s. would it be too much trouble to explain what those codes mean. Did you just know how to write that or is there somewhere in word that walks you through a selection of options and inserts the code? (hope I’m making myself clear).

            • #1177777

              I see that I placed some field codes incorrectly; I have attached a correct version. Sorry about that! I also set the “Space After” for the paragraph containing the category to 0 points instead of 10 points, so that there is no extra spacing between the category and the names.

              The field codes are inspired by macropod’s tutorial macropod’s Word 97-2007 Mailmerge Tutorial: Create Sorted Listings (v1.52). I suggest that you download his zip file and read the tutorial document carefully – it’s not easy stuff!

              BTW, it’s not important but my name is Hans, not Hanz

            • #1177781

              I see that I placed some field codes incorrectly; I have attached a correct version. Sorry about that! I also set the “Space After” for the paragraph containing the category to 0 points instead of 10 points, so that there is no extra spacing between the category and the names.

              The field codes are inspired by macropod’s tutorial macropod’s Word 97-2007 Mailmerge Tutorial: Create Sorted Listings (v1.52). I suggest that you download his zip file and read the tutorial document carefully – it’s not easy stuff!

              BTW, it’s not important but my name is Hans, not Hanz

              I’m so sorry, Hans, for misspelling your name. I guess somewhere I got it in my head and just kept following with the z! So sorry.

              I did the merge with the new codes. However, now the people are not being listed on separate lines. Also, the Congressional Delegation is not listing correctly – it’s not grouping, but listing separately. I looked at the last one you sent and I think it has to do with putting a carrier return after a certain point but I’m not sure which ones. See below:

              Congressional Delegation
              Hon. Anna Eshoo
              Congressional Delegation
              Hon. Jackie Speier

              Assembly
              Hon. Jerry HillHon. Fiona MaHon. Gene MullinsHon. Ira RuskinHon. Ted Lempert (former)

              County Board of Supervisors
              Hon. Mark ChurchHon. Rose Jacobs GibsonHon. Carole GroomHon. Adrienne TissierHon. Mike Nevin (Ret)Hon. Fred Lyon (Ret)Hon. Mary Griffin (Ret)Hon. John Ward (Ret)

              County Elected Officials
              Hon. Greg Munks, SheriffHon. Robert Foucrault, CoronerHon. Tom Huening, ControllerHon. Jean Holbrook, Superintendent, County Office of Education

              Again, thanks, Hans!

              Oh, I see – when I copy and paste the code into a new document, it doesn’t stay the same. I copied it and pasted it so I could compare and when I paste it, it doesn’t stay the same. Why? Is that the problem?

              Yikes, Hans! That mailmerge tutorial does look gnarly I’ll have to tackle that when I have more time! Thanks.

            • #1177786

              You have to make sure that there is a manual line break (Shift+Enter) after the last field code. When copying the field codes, it’s best to display non-printing characters so that you can see the line and paragraph breaks:

            • #1178002

              You have to make sure that there is a manual line break (Shift+Enter) after the last field code. When copying the field codes, it’s best to display non-printing characters so that you can see the line and paragraph breaks:

              Hello again, Hans,

              Everything is working perfectly except that the Congressional Delegation group is not grouping. It is repeating thus:

              Congressional Delegation
              Hon. Anna Eshoo
              Congressional Delegation
              Hon. Jackie Speier

              Can you help?

              Thanks,

              Elaine

            • #1178003

              Make sure that “Congressional Delegation” is exactly the same in all rows where it occurs – for example if there is a space after “Delegation” in one row but not in the other, they are considered to be different categories.

    Viewing 1 reply thread
    Reply To: Word inserts space when field is blank in merge

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: