Mail merge Word - table layout - column width

Solved
amandedouce792212 Posted messages 8 Status Member -  
amandedouce792212 Posted messages 8 Status Member -
Hello,

I am new to the forum, I do some basic tinkering in VBA on Excel, but I know much less about the advanced functions of Word, I hope you can help me.

As part of a project to simplify our documentation, I am trying to set up activity tracking forms using mail merge. The idea is that from an Excel database that lists the activity plan for all locations, I can edit an operating procedure for each location and a checklist for tracking activities.

I managed to create a first draft using Excel's advanced filter and Word's conditional mail merge, but I am stuck on finalizing the document.

I need blank columns at the end of my table to provide space for the dates/signatures of the people when the activities are completed. I wasn't able to add the columns from Word (they disappear during the merge), so I had to create empty columns with a title in the database (laborious in my case, since I have 24 columns for daily activities + 8 columns for bi-weekly + 4 for weekly + 1 for monthly, etc.), is there an easier way to do this?

Since the number of columns is not the same for each activity, I have "stacked" conditional mail merge tables (the first with the column titles and the following ones without) to give the illusion of a single table, but the problem is that the number of columns is not the same and the width of the tables is not identical, so it looks messy. When I adjust the columns and the width of the tables, everything disappears as well during the merge. How can we fix the formatting of the tables so that the layout is preserved during the merge?

Thank you in advance for your help (hoping I have been clear enough ;-) )

Configuration: Windows / Chrome 78.0.3904.70

2 answers

  1. m@rina Posted messages 27459 Registration date   Status Moderator Last intervention   11 562
     
    Hello,

    To be honest, I didn't understand anything...
    You talk about macros, conditional mail merging, columns, etc. In reality, I don't know where you're going with this.
    First of all, conditional mail merging doesn't really exist, except for the one I invented which is not an official feature of Word. So we don't know if you're talking about that or something else.

    Can you be more concise, and thus... clearer? ;) Thank you.

    m@rina

    --
    At least half of the users ask a question and never come back. Sometimes I wonder why I keep responding...
    0
    1. amandedouce792212 Posted messages 8 Status Member
       
      Hello,

      I'm trying to do a mail merge from an Excel table based on the same principle as the link below, which is presented as a conditional mail merge (sorry if that's not the appropriate term)

      https://www.youtube.com/watch?v=F4O5vfYEWkw


      The mail merge includes tables to which I need to add additional columns to make it a fillable document once the documents are printed. I couldn't add these columns from Word (they disappear during the merge), so I had to create empty columns in the Excel table to add them during the mail merge preparation. Is there a simpler way to proceed from Word?

      In the version I managed to create (by adding the columns in the Excel table), the number of columns is not the same in each table, but for readability reasons, I want the tables to have the same width. When I adjust the columns and the width of the tables, everything also disappears during the merge. How can we freeze the formatting of the tables so that the layout is preserved during the merge? (see image below)



      Thank you in advance for your help (hoping I was clearer)
      0
    2. m@rina Posted messages 27459 Registration date   Status Moderator Last intervention   11 562
       
      I imagined this method with a friend 11 years ago. I named it this way but I could have named it something else.
      http://faqword.com/index.php/word/publipostage/416-publipostage-conditionnel-maison#excel-2007-2019

      Too many web thieves have seized this idea without even changing the title... and have taken it for themselves, which tends to annoy me a lot.
      But why not ask these pseudo-authors? (who don't hesitate to turn it into a YouTube?).

      So, the "conditional mail merge" from Faqword is not an official feature of Word...
      It uses a DATABASE field which is nothing more than an SQL query.
      And a field is just a field... As soon as it updates, it eliminates manual customizations, such as adding columns.

      Conclusion: what you want to do is not possible, except for adding columns in Excel, or manipulations after the merge. If all the tables had to be the same, we could have created a macro, but in the opposite case, there are no solutions other than manual ones.

      m@rina
      0
    3. amandedouce792212 Posted messages 8 Status Member
       
      Hello,

      Thank you for your response, I did not mean to offend you, I didn't know that by asking my question on this forum I would be addressing the person who invented the method. Once again, I do not master the advanced functions of Word at all.

      Thank you for this feedback; however, I have a small idea to follow up on the limitations of macros.

      Is it possible to create a macro that would:
      - enforce the size of the first two columns
      - enforce a total width for the table
      - harmonize the widths of the columns (all except the first two)

      If this is possible, applying it to all tables would work, it seems to me?

      What do you think?

      AmandeDouce
      0
    4. m@rina Posted messages 27459 Registration date   Status Moderator Last intervention   11 562
       
      Hello,

      I suspect you didn't mean to offend me! But as you can see, many people are taking over this method without being able to ensure the "after-sales" service!! :))

      So, to answer your question about macros:

      - Yes, it is possible to impose a width on the first two columns of the entire merged document.

      - As for the total width, in theory, yes, we can impose a total width, even if the number of columns is different. However, you really have to try because Word is often unpredictable when it comes to macros and often does whatever it wants.

      - Harmonizing the column widths: I'm not sure what you mean by that... When we macro, we have to be precise, and harmonization is neither a function nor a property! ;))

      The simplest thing would be for you to provide an excerpt from a merged document, stating exactly what you want.

      m@rina
      0
    5. amandedouce792212 Posted messages 8 Status Member
       
      Re-hello,

      thank you once again for your feedback,
      As I don't macro much on word (and very little on excel) and I'm also not familiar with the advanced functions of word (as stated in my first message), it's not easy to use the precisely accurate vocabulary

      after checking, the proper term is therefore "standardize" with the "distribute" function and not "harmonize".

      a small diagram to try to clarify



      thank you in advance

      amandedouce
      0
  2. m@rina Posted messages 27459 Registration date   Status Moderator Last intervention   11 562
     
    Hello Elodie,

    So I've tried a lot of things, but as I told you, Word is very temperamental when it comes to tables. No matter how much we set width indications, it doesn’t always follow them, and there’s no logic to it. For proof, the macro I'm giving you below doesn’t work well with some tables, but if you run it a second time, things tend to get back in place.

    So you can test this, and feel free to run it a second time:

    Sub tablos()
    Dim Tablo As Table
    For Each tablo In ActiveDocument.Tables
    With tablo
    .Rows.LeftIndent = CentimetersToPoints(0)
    .PreferredWidthType = wdPreferredWidthPercent
    .PreferredWidth = 100
    .Columns(1).SetWidth ColumnWidth:=CentimetersToPoints(0.5), RulerStyle:=wdAdjustFirstColumn
    .Columns(2).SetWidth ColumnWidth:=CentimetersToPoints(2), RulerStyle:=wdAdjustFirstColumn
    End With
    Next
    End Sub

    m@rina

    --
    At least half of the users ask a question and never come back. Sometimes I wonder why I keep answering...
    0
    1. amandedouce792212 Posted messages 8 Status Member
       
      Thank you very much, I ran the test several times and it starts to look like aligned tables :-) However, each time I execute it, the 3rd column of the 1st table widens while it had the correct size on the 1st run. Do you know why?

      0
    2. m@rina Posted messages 27459 Registration date   Status Moderator Last intervention   11 562
       
      No, it's incomprehensible, Word just does whatever it wants... The macro only enforces a fixed width for all the tables and for the first columns. Even that, Word doesn't obey as one would expect.

      If a width is chosen in % rather than fixed, it's not better... And since there's no logic in the tables, we can't test anything else. If each section contained an identical number of tables and these tables had the same number of columns according to the table number, we could re-test, but that's not the case a priori.

      m@rina
      0
    3. amandedouce792212 Posted messages 8 Status Member
       
      Thank you for accompanying me on the subject. I think I will consider presenting the documents by separating the tables; the slight differences in the columns after applying the macro will be less noticeable, and since all the tables will have the same width, it will remain "presentable."
      0