Run-time error '5941':

Joined
May 21, 2013
Messages
1
Reaction score
0
I am getting the below error when i am trying use the mail merge function in application.

Run-time error '5941':
The requested member of the collection does not exist.


Code is as below line highlighted in bold is where error occurs:

Private Sub MergeMailDoc(as_Path As String, as_DocName As String, as_Where As String)
Dim ls_DbConnection As String
Dim ls_SqlStatement As String
Dim ls_DocPathName As String
Dim ls_DocName As String

Windows("ExamSpec.doc").Activate
Selection.EndKey Unit:=wdStory

ls_DocName = as_DocName
ls_DocPathName = as_Path & "\" & ls_DocName

If Len(Dir(ls_DocPathName)) = 0 Then
ls_DocName = "NoExamSpec.doc"
ls_DocPathName = as_Path & "\" & ls_DocName
End If

Application.Documents.Open ls_DocPathName

ls_DbConnection = as_Path & "\Prs_Data.mdb"

ls_SqlStatement = "SELECT * FROM `ExamSpecReport` " & as_Where

Documents("ExamSpec.doc").Application.Run "Mail_Merge", ls_DocName, ls_DbConnection, ls_SqlStatement

Documents("ExamSpec.doc").Application.Run "AppendMailMerge"

Documents(ls_DocName).Close False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top