troubleshooting Question

MSAccess driven mail merge with word doesn't work on Server 2019 with Office 2016

Avatar of Samantha Moore
Samantha MooreFlag for United States of America asked on
Microsoft OfficeMicrosoft AccessMicrosoft Word
2 Comments1 Solution11 ViewsLast Modified:
In the middle of a port of an MSAccess application from a server 2006 using MSAccess 2010 with Jet databases, to a server 2019 running Office 2016 with an SQLServer 2019.  When my access application attempts to run word mailmerge to print some stuff, then I get the message:  

Error 4605 - The OpenDataSource method or property is not available because this command is not available for reading. - in MailMergePatientDocument()

On the original environment it works like a charm.  On the ported environment it always gives me that error.  If I pick the same document and run a mail merge from within word, there is no problem connecting to the new SQLServer database.  It is when I have the access application fire up word and do the job that it doesn't work.  The process fails on the .ActiveDocument.Mailmerge.Execute instruction .

Any insights would help.

The code that does this:
Private Sub MailMergePatientDocument(InputFilename As String, Optional PatientID As Long = 0, Optional DoubleSided As Boolean = False)
    Dim QryPatient As String
    Dim DatabaseType As String
    Dim objapp As Object
    QryPatient = "SELECT * from [tblPatientInfo]"
    If PatientID <> 0 Then
        QryPatient = QryPatient & " WHERE [PatientID]=" & PatientID
    End If
    On Error GoTo error
    Set objapp = CreateObject("Word.Application")
    With objapp
        .Visible = True 'Make it visible
        .Documents.Open InputFilename, False, True 'Open the Mailmerge Document
        .ActiveDocument.Mailmerge.MainDocumentType = wdFormLetters
        .ActiveDocument.Mailmerge.Destination = 0 'wdSendToNewDocument
        '.ActiveDocument.MailMerge.Destination = 1 'wdSendToPrinter
        'Depending on how the database is configured:
        DatabaseType = GetSystemParm("DATABASETYPE")
         'Attach the data source to the mail merge document
        If DatabaseType = "Jet" Then
            .ActiveDocument.Mailmerge.OpenDataSource Name:="D:\Bear\BearInterface.mdb", _
            .ActiveDocument.Mailmerge.OpenDataSource Name:="", _
                Connection:="DSN=BearDatabase;DATABASE=BearDatabase;", _
        End If

'      Execute the merge
        .ActiveDocument.Mailmerge.Execute pause:=True
        If DoubleSided Then
            .ActiveDocument.PrintOut ManualDuplexPrint:=True, background:=False
            .ActiveDocument.PrintOut ManualDuplexPrint:=False, background:=False
        End If
        .ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
        .Quit SaveChanges:=wdDoNotSaveChanges 'close all documents

    End With
    Exit Sub
    MsgBox "Error: " & Err.Number & " - " & Err.Description & " - in MailMergePatientDocument()"
    On Error Resume Next
    objapp.Quit SaveChanges:=wdDoNotSaveChanges
    On Error GoTo 0
    Exit Sub
End Sub

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros