MailMerge cc with VBA table issue

Dear Experts,
My user requested to use cc fields in his mail merge, so I refereed to the solution by GrahamSkan(2011-08-14) and tried to run it.
After having issues, I started to debug, and realized that I am not really accessing the recipients' list in mail merge.

Here is what I did.
1. Run the mail merge to create the list, save and close it.  I saved the merged documents as Test.docx, verified that it has 3 sections.
2. Created a module containing the code from GrahamSkan's post.  Compiled.
3. Ran the code.  It does not send.

If I strip the Table portion of the code and hard code in the recipients names, the code will work and it will send out 3 emails.
When I debug, the variable "DataRange" is set to Nothing.  That is why I think I am not accessing the recipients list.
Am I saving the merged documents in the wrong format?  I do not think I have a clear understanding of how the recipients are stored in "ActiveDocument.Table" object.

Please advise.

Code.txt
yballanAsked:
Who is Participating?
 
yballanConnect With a Mentor Author Commented:
I figured it out, I was reading the instructions wrong, and referring to a wrong document for e-mail addresses.
0
 
Rgonzo1971Commented:
Hi,

Could you send a dummy ?

Regards
0
 
yballanAuthor Commented:
Dear Rgonzo1971,

I am not understanding your question, do you mean a dummy email without mail merge?
I can send a mail if I hard code the TO: address.  It is not fetching from the recipient list, which I am assuming I can access by

 With ActiveDocument.Tables(1).Range,  or some type of commands like that.
I cannot seem to be able to get to the info that were merged into Word from Excel during mail merge.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
Rgonzo1971Commented:
like  Test.docx
0
 
yballanAuthor Commented:
Oh, OK.  Here it is.  This is after the merge.
-test1.docx
0
 
Rgonzo1971Commented:
Don't see the to nor the CC and there is no table
0
 
yballanAuthor Commented:
No, It is already merged with an Excel file with all of the info in them.  So it is the end results from Mail Merge, just as the code creator GrahamSkan's post describes.  So I was assuming that the recipients were included in the ActiveDocument.Table.
0
 
Rgonzo1971Commented:
could you send a dummy of the  ActiveDocument used
0
 
yballanAuthor Commented:
I use MailMergeCC.docx then merge EmailAddress.xlsx, save the merged documents as test1.docx, then run my code.  Please see attached.
-MailMergeCC.docx
-EmailAddresses.xlsx
0
 
yballanAuthor Commented:
Dear Experts,

After researching for a while, I got the half of the code working.  I was executing the code after the merge was completed, but now I execute before "Edit indivigual Letters" step and I can at least see the DataFields attached to DataSource.  However, I still cannot access all of the records in the DataSource.  

How can I get the pointer to advance to the next record in DataFields?  If I run this code:
ActiveDocument.MailMerge.DataSource.DataFields("CCAddress").Value
It only points to the first record.

In the code I referred to earlier, this is accomplished by using Table(), as in this piece of code, but when I run this, my Table points to "Nothing".  Please advise.

Set Maillist = ActiveDocument
 For j = 1 To NumPages
    Set oItem = oOutlookApp.CreateItem(olMailItem)
    With oItem
        .Subject = mysubject
        .Body = Source.Sections(j).Range.Text
        Set Datarange = Maillist.Tables(1).Cell(j, 1).Range
        Datarange.End = Datarange.End - 1
        .To = Datarange
       
        'code for adding a CC recipient
         Set Datarange = Maillist.Tables(1).Cell(j, 4).Range
         Datarange.End = Datarange.End - 1
        .CC = Datarange
        'end of code for adding a CC recipient
     
           .Send
    End With
    Set oItem = Nothing
Next j
0
 
Rgonzo1971Commented:
I need to know whre is graham's solution
0
 
yballanAuthor Commented:
I realized my misunderstanding, and was able to get the original instruction to work.
0
All Courses

From novice to tech pro — start learning today.