?
Solved

Run word mailmerge from Access

Posted on 2014-02-07
8
Medium Priority
?
996 Views
Last Modified: 2014-05-10
Dear Experts,

As part of a bigger project I need to be able to do the following from Access.

Open up an already prepared word email mailmerge doc and run the mail merge.

Please note the email addresses for the mailmerge is already linked up to the word doc & has nothing to do with the access database.

Can anybody help?
0
Comment
Question by:correlate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39841270
Albert D. Kallal has a truly great mail merge sample, I'm not sure what exactly you need so this may be a bit of an overkill, but it is definitely worth looking at!

http://www.kallal.ca/wordmerge/index.html
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39841285
If all you want is to open a ready made mailmerge document and execute the merge try this (not tested):

Sub Demo()

   Dim StrFullDocPath As String
   Dim oApp As Object
   
   'Path to the word document
   StrFullDocPath = "C:\Test\TestDocument.docx"
   
   If Dir(StrFullDocPath ) = "" Then
      MsgBox "Document not found."
   Else
      'Create an instance of MS Word
      Set oApp = CreateObject("Word.Application")
      oApp.Visible = True
      
      'Open the Document
      oApp.Documents.Open filename:=StrFullDocPath 
   End If

   With oApp
      With .MailMerge 
         .Destination = wdSendToNewDocument 
         .Execute          
      End With
   End With

   oApp.Close
   Set oApp = Nothing

End Sub

Open in new window

0
 

Author Comment

by:correlate
ID: 39841295
Thanks for this - you code above looks like it will do exactly what I'm after, I have tried it but unfortunately I got an error (438 - Object doesn't support this property or method) - it highlights       With .MailMerge - looking at the code it looks like its trying a document rather than an email mailmerge?

Any ideas
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39841364
HI,

pls try

   With oApp
      With ActiveDocument.MailMerge 
         .Destination = wdSendToNewDocument 
         .Execute          
      End With
   End With

Open in new window

Regards
0
 

Author Comment

by:correlate
ID: 39841425
HI thanks for that

Alas I'm getting "Object required" pointing to this line ..

      With ActiveDocument.MailMerge
0
 
LVL 27

Accepted Solution

by:
MacroShadow earned 1600 total points
ID: 39841490
Try this (once again not tested):

Sub Demo()

    Dim StrFullDocPath As String
    Dim oApp As Object
    Dim oDoc As Object

    'Path to the word document
    StrFullDocPath = "C:\Test\TestDocument.docx"

    If Dir(StrFullDocPath) = "" Then
        MsgBox "Document not found."
    Else
        'Create an instance of MS Word
        Set oApp = CreateObject("Word.Application")
        oApp.Visible = True

        'Open the Document
        Set oDoc = oApp.Documents.Open(FileName:=StrFullDocPath)
    End If

    'Merge to email
    If oDoc.State = wdMainAndSourceAndHeader Or oDoc.State = wdMainAndDataSource Then
        With oDoc.MailMerge
            .Destination = wdSendToEmail
            .Execute
        End With
    End If

    'Clean-up
    oDoc.Close
    oApp.Close
    Set oDoc = Nothing
    Set oApp = Nothing

End Sub

Open in new window

0
 
LVL 52

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 400 total points
ID: 39841493
hi.

forgot the point

With oApp
      With .ActiveDocument.MailMerge 
         .Destination = wdSendToNewDocument 
         .Execute          
      End With
   End With

Open in new window

Regards
0
 

Author Closing Comment

by:correlate
ID: 40055989
Brilliant, thank you for your help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question