• Mail merge to table (Word 2000, SR1)

    Author
    Topic
    #362204

    I’m doing a mail merge which creates a consecutive table for each record (i.e., the table has separate rows for each field in the record). I’ve set the merge option to not print a line if the field is blank; however, I’d like to be able to delete the table row that contains the field as well. Is there a way to do this?

    Also, sometimes the first field for several records contains the same data (e.g., Company Name = Widgets, Int’l.), even though the following field (e.g,. employee name) is different. Is there a way to do check so that if the data in the field in preceding record matches the data in the field in the current record, the current field can be left blank?

    confused I hope I’ve explained this clearly. If not, I’ll try to clarify. I hope I’m not asking for the impossible.

    Thanks very much in advance, as always.

    Viewing 1 reply thread
    Author
    Replies
    • #549557

      I am not merge guru, so I hope others chime in.

      #1: Positioning a {Skip Record If…} field on a blank line prior to the table row should enable you to should avoid adding rows with a particular field empty.

      #2: ??!! Would be nice to know the answer.

    • #549559

      Edited by HansV to update link that no longer worked

      Hi Shatzie:

      I have a solution to the second part, not the first. Here are two tips that I learned–one from Cindy Meister’s home page & one from Allen Wyatt, who publishes Word Tips. Cindy Meister was disucssing how to create an address book, which might contain duplicate entries.

      From Mail Merge FAQ by Cindy Meister:

      Suppress duplicate records
      Similarly to a complex merge, or for creating an index header in the catalog merge, here again you can use a combination of SET and IF fields in the main merge document to check for duplicate information and suppress merge fields for a record if they are the same as in the previously merged record. As for the other merge types, here you also need to pre-sort the records before merging.

      Example: { IF { REF Check } “{ MERGEFIELD FIRSTNAME } { MERGEFIELD LASTNAME }”
      “{ MERGEFIELD FIRSTNAME } { MERGEFIELD LASTNAME }
      { MERGEFIELD ADDRESS }
      { MERGEFIELD CITY }” }
      { SET Check “{ MERGEFIELD FIRSTNAME } { MERGEFIELD LASTNAME }”}

      Note how this works. It inserts the first record because, by definition, the first record cannot yet be a duplicate. It then creates a bookmark by the name of Check,{SET Check ” “}etc.. It holds this as a variable & then assigns a value to it. The value is contained between the double quotes. Here, the value (result) will be the “{Mergefield FirstName} {Mergefield LastName}” that was just inserted.

      Next, the { IF { REF Check } examines this value & asks if it’s not equal to () the next {Mergefield FirstName} {Mergefield LastName}. Notice that while it appears to examine itself,

      i.e. is { MERGEFIELD FIRSTNAME } { MERGEFIELD LASTNAME } { MERGEFIELD FIRSTNAME } { MERGEFIELD LASTNAME }

      it really compares the results of the current field, to the next one merged. If they are not the same, it puts in the name, address, & city, each on its own line (that’s where the marks come in). If they are the same, it inserts nothing. (While not shown, you could have a space & pair of double quotes after the double quotes which follows the {Mergefield City}.)

      I do notice that each time the SET field is inserted & then deleted, it leaves behind a paragraph mark. This marks the number of duplicates it has skipped, which may or may not be useful.

      An alternative solution from Allen Wyatt’s Word Tips:

      MailMerge: Query Conditional Fields (Alternative to If, Then, Else)
      from Allen Wyatt WordTips (edited)

      You should note that you cannot use Word’s conditional mail-merge fields to compare values in any record other than the current one. [However, you can use a SET field to create such a condition by holding values from the previous record. See MailMerge: Address Book e.g.] It would be very nice to compare the contents of a data field in the current record with the contents of the same data field in the previous record, but Word will unfortunately not allow it.

      One possible workaround to this shortcoming–if you are using an Excel worksheet as your data source–is to simply copy the controlling field (column) to another column, and then offset it by one row. Here is an example:

      ITEM	CATEGORY	OLDCAT
      Dogs	1	
      Cats	1	1
      Birds	2	1
      Pigs	3	2
      

      As Word processes each record of the data source, the value of the OldCat data field is the same as the contents of the Category data field in the previous record. Thus, you could use a compound field such as the following to check and act upon the comparison between the fields:

      {IF {MERGEFIELD Category} {MERGEFIELD OldCat} “first text” “second text”}

      Hope this helps.

      • #549634

        Wow!! It’s a little complicated for me, but I think I can give it a shot. I’ll try all your suggestions and let you know what works.

        You guys are champs!

    Viewing 1 reply thread
    Reply To: Mail merge to table (Word 2000, SR1)

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

    Your information: