Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Run word mailmerge from Access

Posted on 2014-02-07
8
Medium Priority
?
1,020 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 53

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 53

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

650 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