Solved

Run word mailmerge from Access

Posted on 2014-02-07
8
954 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
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!

 
LVL 51

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 400 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 51

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 100 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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 …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

696 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