LarryDeLaruelle
Technical User
In earlier versions of access, this code worked fine to merge and save a document.
Private Sub cmdMerge_Click()
Dim strFileName As String
Dim strFilePath As String
Dim strMergeFile As String
Dim objWord As New Word.Application
Dim objDoc As Word.Document
objWord.Application.Visible = False
Set objDoc = objWord.Documents.Open("G:\Database\TCC_KidCare\WordDocs\" & strMergeFile)
‘This is the line that errors – Run Time Error 5832; Requested object is not available
objDoc.MailMerge.Destination = wdSendToNewDocument
objDoc.MailMerge.Execute
objWord.Application.Documents(1).SaveAs (strFilePath & strFileName)
objWord.Application.Documents(2).Close wdDoNotSaveChanges
objWord.Application.Documents(strFileName & ".doc").Close
objWord.Application.Quit
Set objWord = Nothing
Set objDoc = Nothing
End Sub
It now errors on the line objDoc.MailMerge.Destination = wdSendToNewDocument.
We are using Office 2010, 32 Bit. I have set the VBA references (in Access) to the 14.0 version of Word and Office.
I have manually processed the merge in Word without a problem.
Any assistance will be greatly appreciated.
Larry De Laruelle
Private Sub cmdMerge_Click()
Dim strFileName As String
Dim strFilePath As String
Dim strMergeFile As String
Dim objWord As New Word.Application
Dim objDoc As Word.Document
objWord.Application.Visible = False
Set objDoc = objWord.Documents.Open("G:\Database\TCC_KidCare\WordDocs\" & strMergeFile)
‘This is the line that errors – Run Time Error 5832; Requested object is not available
objDoc.MailMerge.Destination = wdSendToNewDocument
objDoc.MailMerge.Execute
objWord.Application.Documents(1).SaveAs (strFilePath & strFileName)
objWord.Application.Documents(2).Close wdDoNotSaveChanges
objWord.Application.Documents(strFileName & ".doc").Close
objWord.Application.Quit
Set objWord = Nothing
Set objDoc = Nothing
End Sub
It now errors on the line objDoc.MailMerge.Destination = wdSendToNewDocument.
We are using Office 2010, 32 Bit. I have set the VBA references (in Access) to the 14.0 version of Word and Office.
I have manually processed the merge in Word without a problem.
Any assistance will be greatly appreciated.
Larry De Laruelle