Results 1 to 3 of 3
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Mail Merge newbie

    I have the below code in my attempt to run a mail merge. I keep getting the run-time error:
    "Automation error
    "Unspecified error"



    on the highlighted line of code. Help/direction is much appreciated!

    Code:
    Function funMergeIt()
        Dim strPathFile As String, strTable As String
        Dim objDesktop As Object
        Dim ObjWord As Word.Document
        
        Set objDesktop = CreateObject("WScript.Shell")
        strPathFile = objDesktop.SpecialFolders("Desktop") & "\ContactListEnvelop.docx"
        
        Set ObjWord = GetObject(strPathFile, "Word.Document")
        
        ObjWord.Application.Visible = True
        ObjWord.MailMerge.OpenDataSource _
        Name:="C:\Data\DMPhoneList_Fe_NEW.accdb", _
        LinkToSource:=True, Connection:="QUERY qryDMMailMerge", _
        SQLStatement:="SELECT * FROM [qryDMMailMerge]"
        ObjWord.MailMerge.Execute
    End Function

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    bud,

    are you aware that 2010 macros have a mail merge function in it?

    as far as the error, are you sure you can use GETOBJECT() with an actual word document? I'm not sure. I just have never seen it used before. Whenever I see it used, it's being used to fetch an actual application object.

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I was unaware of the macros. I appreciate the information. I'll resort to the macro. No need for unnecessary code! Thanks again.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Mail Merge
    By sakhtar in forum Access
    Replies: 8
    Last Post: 09-20-2020, 09:10 AM
  2. Mail Merge with Access
    By missesclick in forum Access
    Replies: 6
    Last Post: 12-09-2010, 01:28 PM
  3. Mail Merge
    By Nixx1401 in forum Access
    Replies: 1
    Last Post: 02-15-2010, 10:51 AM
  4. Mail merge
    By grgerhard in forum Forms
    Replies: 0
    Last Post: 04-25-2006, 05:06 PM
  5. Mail Merge problem
    By kfergus in forum Programming
    Replies: 0
    Last Post: 04-24-2006, 01:06 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums