Results 1 to 14 of 14
  1. #1
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    NOTE: This post and all replies to it have been split off from Word 97-2007 Mailmerge Tutorial: Create Sorted Listings (v1.52)
    HansV


    When I run this it does group them by the key field but it does so in a separate table instead of adding rows to one table per key field. Am I missing something? I used the code and created the tablejoin macro. I tried running the macro before the merge and after the merge but neither option worked. Any suggestions would be greatly appreciated

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='MOSTATE' post='769076' date='04-Apr-2009 02:52']When I run this it does group them by the key field but it does so in a separate table instead of adding rows to one table per key field. Am I missing something? I used the code and created the tablejoin macro. I tried running the macro before the merge and after the merge but neither option worked. Any suggestions would be greatly appreciated [/quote]
    Hi Mostate,

    The table merge does indeed output a series of tables, which is why you need the macro. There's no point in running the macro until the merge has been run and, because it processes the 'ActiveDocument', the document holding the merged output must be the active one. If you've added the macro to your 'Normal.dot' template or the merged output file, simply activating the merged output file, then pressing Alt-F8 and double-clicking 'TableJoiner' should get things running nicely.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Hi Paul,
    Thanks for the reply. I followed your suggested steps and the output file still shows the results in a separate table. It is not merging the rows with the same key field into one table. The macro is saved in the Normal template. I am using Word 2007, would that make a difference?

    Thanks again for your help!!
    MOState

    [quote name='macropod' post='769137' date='03-Apr-2009 16:39']Hi Mostate,

    The table merge does indeed output a series of tables, which is why you need the macro. There's no point in running the macro until the merge has been run and, because it processes the 'ActiveDocument', the document holding the merged output must be the active one. If you've added the macro to your 'Normal.dot' template or the merged output file, simply activating the merged output file, then pressing Alt-F8 and double-clicking 'TableJoiner' should get things running nicely.[/quote]

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='MOSTATE' post='769333' date='06-Apr-2009 22:33']Hi Paul,
    Thanks for the reply. I followed your suggested steps and the output file still shows the results in a separate table. It is not merging the rows with the same key field into one table. The macro is saved in the Normal template. I am using Word 2007, would that make a difference?

    Thanks again for your help!!
    MOState[/quote]
    Hi Mostate,

    As I've already explained, the merge to table process generates a series of separate tables. You have to run the macro against the merged output after the merge process has been completed. The macro joins each set of tables together. Using Word 2007 doesn't make any difference here.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    I did run the macro against the merged output and it does generate a series of separate tables. The problem is it is not joining the tables that have the same identifier, these are staying in separate tables. I should have one table that has 5 rows with the identifier 12345 but instead I have 5 separate tables. Sorry to be a pest but I have followed all the steps and can't figure out why it's not working.

    Thanks for your assistance,

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='MOSTATE' post='769536' date='07-Apr-2009 22:23']I did run the macro against the merged output and it does generate a series of separate tables. The problem is it is not joining the tables that have the same identifier, these are staying in separate tables.[/quote]
    Hi Mostate,

    There are only two possible explanations I can think of for this:
    1. The column widths you've defined are too narrow for some of the data and they're changing their widths. You can prevent this via Table|Table Properties|Table > Options and unchecking the 'Automatically resize to fit contents' option; or
    2. Your implementation of the field coding is leaving more than a single, empty paragraph between the tables initially created via the merge process.

    If you care to post a (sanitized) copy of your mailmerge main document, with just the merge fields, I can take a closer look at it.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Thanks so much for taking the time to look at this for me. I have attached the requested sanitized copy of the main document.

    Thanks again!!
    Attached Files Attached Files

  8. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='MOSTATE' post='769689' date='08-Apr-2009 22:50']Thanks so much for taking the time to look at this for me. I have attached the requested sanitized copy of the main document.

    Thanks again!![/quote]Hi Mostate,

    The problem you're having is caused by the fact you've set the 'text wrapping' to 'around' for the table. You can correct this via Table|Table Properties|Text Wrapping|None. If you need to have 'text wrapping' set to 'around' for the final table, either do it after the macro has run, or add another process to the macro to do it for you. Do note, though, that tables with 'text wrapping' set to 'around' cannot span more than one page.

    The other issue you're likely to have is that the table header row will be repeated for each line. You should be able to achieve a single header per table by inserting the header row immediately before the final double quote in "{MERGEFIELD ESCTYDIS }{SET Key {MERGEFIELD ESCTYDIS
    }}". Depending on the structure of the rest of your document, you may have to add an extra paragraph, which the macro will delete, ahead of the header row.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  9. #9
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Good morning,
    I changed the properties of the table and set text wrapping to none. I moved the header row before the last double quote. When I run the tablejoiner macro it combines the header row and the first row of the table but it still does not combine the rows with the same identifier into the table. There is an extra hard return that can be deleted between the table rows and then it will combine the rows. However, when I place additional text after the table this doesn't work. Let me know if you need further information.

    Thanks again,
    Mostate

    [quote name='macropod' post='769815' date='08-Apr-2009 17:14']Hi Mostate,

    The problem you're having is caused by the fact you've set the 'text wrapping' to 'around' for the table. You can correct this via Table|Table Properties|Text Wrapping|None. If you need to have 'text wrapping' set to 'around' for the final table, either do it after the macro has run, or add another process to the macro to do it for you. Do note, though, that tables with 'text wrapping' set to 'around' cannot span more than one page.

    The other issue you're likely to have is that the table header row will be repeated for each line. You should be able to achieve a single header per table by inserting the header row immediately before the final double quote in "{MERGEFIELD ESCTYDIS }{SET Key {MERGEFIELD ESCTYDIS
    }}". Depending on the structure of the rest of your document, you may have to add an extra paragraph, which the macro will delete, ahead of the header row.[/quote]

  10. #10
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='MOSTATE' post='769865' date='09-Apr-2009 23:07']I changed the properties of the table and set text wrapping to none. I moved the header row before the last double quote. When I run the tablejoiner macro it combines the header row and the first row of the table but it still does not combine the rows with the same identifier into the table. There is an extra hard return that can be deleted between the table rows and then it will combine the rows. However, when I place additional text after the table this doesn't work. Let me know if you need further information.[/quote]
    Hi Mostate

    Care to post an updated copy of your mailmerge main document?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  11. #11
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    I don't mind at all. Here it is..

    Thanks for all your time and consideration!!
    Attached Files Attached Files

  12. #12
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='MOSTATE' post='770257' date='13-Apr-2009 22:18']I don't mind at all. Here it is..

    Thanks for all your time and consideration!![/quote]
    Hi Mostate,

    OK, the problem you're now having is that you're trying to output some text (plus mergefields) after the IF statement that creates the tables. The result is that this causes the extra material to be inserted after each record, instead of after each group. With the previous rendition of your document, it wasn't apparent that the extra material was instended to appear after the table.

    If you revisit the tutorial, and review the item titled "Insert Additional Text Before and After the Repeated Data", you'll see that the coding required to output text after the table is quite different to what you've been using. You could easily enough adapt that field coding to work with the tables, except for the fact that your document also has a mergefield after the table. Unless you have a field in (or add a field to) the data source to indicate which is the last record in each group, plus build the extra logic in the field coding to process this, you can't output any further mergefields after the repeated data.

    Alternatively, you can quite easily add mergefields & text before the repeated data, per the example titled 'Merge Records By Category to a Table With Heading Rows and/or Insert Additional Text Before the Table' in the latest iteration of the tutorial (V1.3). This might work for you and would be a lot less work than modifying the data source and developing & testing the necessary field coding.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  13. #13
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Where can I find that lastest version of the tutorial V1.3?


    Thanks!!

  14. #14
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='MOSTATE' post='770281' date='14-Apr-2009 00:07']Where can I find that lastest version of the tutorial V1.3?


    Thanks!![/quote]
    Hi Mostate,

    It's the first item in this thread - the attachment (tutorial) has been updated.
    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
  •