Results 1 to 2 of 2
  1. #1
    amallon is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2015
    Posts
    7

    Running Mail Merge from Access to Word works fine once, fails second time around - runtime error 462


    Hi,


    Im trying to launch a mail Word merge from Access 2007. Everything works fine first time around, but on a second attempt to run the mail merge I get a runtime error 462 - the remote server machine does not exist or is unavailable. I think this is something to do with VBA not releasing Word but I can’t get a fix. This is my code? Any suggestions?


    Private Sub Command13_Click()
    Dim wdApp As Word.Application
    Dim wdDoc As Word.Document
    Dim strMainDocNm As String
    Dim strDataDocNm As String
    Dim oRange As Word.Range


    SQLStr = "select * from PaymentsOnlyTemp"
    '[OrderDate] >#" & Me!txtDate & "#"
    MergeAllWord (SQLStr)




    ' Create an instance of MS Word
    Set oApp = CreateObject(Class:="Word.Application")
    oApp.Visible = True

    'Open the Document
    oApp.Documents.Open FileName:="C:\MassCards\Letter.doc"


    'Run Merge Against TXT File
    Set wdApp = Word.Application
    strMainDocNm = "C:\MassCards\Letter.doc"
    strDataDocNm = "C:\MassCards\merge.888"


    With wdApp
    '.DisplayAlerts = False
    .Application.Visible = True
    Set wdDoc = .Documents.Open(FileName:=strMainDocNm)
    With wdDoc
    With .MailMerge
    .MainDocumentType = wdFormLetters
    .OpenDataSource Name:=strDataDocNm, LinkToSource:=True
    .Execute
    End With
    .Close SaveChanges:=False
    End With
    End With


    Set wdApp = Nothing
    Set wdDoc = Nothing






    End Sub
    Last edited by amallon; 07-18-2015 at 01:09 AM. Reason: Error in title

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Access has the ability to mail merge internally. These are called reports.

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

Similar Threads

  1. Replies: 6
    Last Post: 08-13-2014, 10:32 PM
  2. Error when creating mail merge doc or any word doc
    By maxmaggot in forum Programming
    Replies: 5
    Last Post: 08-25-2013, 01:35 PM
  3. Mail merge from from Access to Word
    By williamgladstone in forum Access
    Replies: 1
    Last Post: 03-22-2011, 12:00 PM
  4. Help fine tuning mail merge from switchboard
    By saythein in forum Access
    Replies: 1
    Last Post: 09-06-2010, 01:14 AM
  5. Mail Merge from Access to Word
    By Rachelkm2 in forum Programming
    Replies: 1
    Last Post: 05-29-2009, 02:49 PM

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