[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 687
  • Last Modified:

Mail merge with a table and have every other row be an alternate color

I have a mail merge document that I create out of Microsoft Access.  I have field code in the merge document to print a contiuous list with group headers.  I have the details for each group in a table and I want the table to print with alternate colors.  I know how to apply the alternate row color to a table in a regular document using the style formatting option.  I believe the problem here is that the field code logic is actually treating every line item as an individual table, thus there are no alternate lines to color.  Is there anyway to present my data in the same layout but get every other detail record to alternate color.  Please see the attached documents.
WordDocExample.jpg
WordDocCode.jpg
0
arothermel
Asked:
arothermel
  • 5
  • 4
  • 3
1 Solution
 
GrahamSkanCommented:
It is possible to apply an alternate-row colouring style to the main table and have the style appear in the (directory-type) result document.

It is not easy to see what is happening from a picture, but you seem to have more than one single-row table in the main document (and in the result document).
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
I can get a merged file to look like the image below... would that work?
Merged-Table-Color-Rows.jpg
0
 
arothermelAuthor Commented:
Yes,, as long as the group headers will still work.  That's why the table is in the code twice.  It checks if the record is the first record in a new group and if it is it prints the header and the details, if it is not it prints just the details.  The details are in the table.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
Joanne M. OrzechManager, Document Services CenterCommented:
Ok - well, I changed the merge file type to "Directory" and I created a two row table and colored the second row....let me know if that explains it enough....
0
 
arothermelAuthor Commented:
I think I've figured some more of this out.  The document is being created out of Access using Albert D. Kallal word merge code that is available on the internet.  I believe there is something in his code that no matter what I do to change the document type from a form letter to a directory it always reverts back to a form letter the next time it is opened.  When word is creating the document as a form letter it is placing each table row in a different section so it never alternates the color as there is only one record per table.  I'm going to throw this question over to the access forum and see if anyone there knows how to create a directory document using the mail merge code from Albert Kallal.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Why do you need code to merge?
0
 
GrahamSkanCommented:
Can you show us the code or tell us where we can find it?

There is a parameter that determines the output type.

It sounds as if the code is doing
Doc.MailMerge.MainDocumentType =wdFormLetters

You need
Doc.MailMerge.MainDocumentType =wdDirectory 'or wdCatalog (no difference)

0
 
arothermelAuthor Commented:
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
I just reviewed the little program.  When your Word document comes up, go to Tools, Letters and Mailings, Mail Merge, and go back to step one where you select the type of document.  At that point, you can make it a directory.

Directory-Mail-Merge.jpg
0
 
GrahamSkanCommented:
Thanks.

That Access database contains a VBA-base facility for managing MailMerge. It appears to do the same job as the Mail Merge wizard that comes with Word. It is not clear if it adds any extra value, but in the couple of places that it sets the document type it is hard-coded to Form Letters.

0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Thanks Graham - After clicking the button to run the merge and it launched Word and opened my file, I just changed it to directory.....and completed the merge manually....

I guess it's a nice program if you're not too familiar with mail merge.

0
 
arothermelAuthor Commented:
I figured it out.  I had previously changed the main document type in the code to wddirectory but it didn't seem to "stay".  The problem was that in the code where the merged document was being created from the saved template, there was no specification for the main document type.   This made the document open as a form letter, which must be the default even though the template was saved as a directory.  I added the code to specify the document type and it now works.  The bottom line is that Albert's code works beautifully for form letters but if you want to use it to create a directory type document you have to change all references to wdformletters to wddirectory and modify the code sample below to insert a line specifying the document type.

In the function RidesMergeWords add a line specifying the document type:

With WordDoc.MailMerge
      .Destination = 0        ' 0 = new doc
      .MailAsAttachment = False
      .MainDocumentType = wddirectory
      .MailAddressFieldName = ""
      .MailSubject = ""
      .SuppressBlankLines = True
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now