G
Guest
I have a databse where I've set up a mail merge squence to output certain
records to a word document that's already created. This worked fine when my
database was in Access '97 but we've upgraded to Access 200 and now it
doesn't work. I keep getting told that there's an error and that the object
isn't defined.
This is my merging code;
Private Sub MergeIt()
Dim objWord As Word.Document
Set objWord =
GetObject("\\UM-UABSYS\Literature\LitLists\RefListMergeTemplate.doc",
"Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource
Name:="\\S:\UM-LABSYS\Literature\LitLists\LiteratureList_XP.mdb", _
LinkToSource:=True, Connection:="TABLE TempMerge",
SQLStatement:="SELECT References.Author, References.Year, References.Title,
References.[Publisher_Report_to], References.[In], References.Journal,
References.Volume, References.Edition, References.Pages FROM References,
TempMerge WHERE References.ID = TempMerge.ref_id"
objWord.MailMerge.Execute
End Sub
Private Sub cmdMerge_Click()
Dim i As Integer
Dim strSQL As String
Dim first_time_through As Boolean
i = 1
'delete previous records
DoCmd.RunSQL "delete * from TempMerge"
'strSQL = "insert into TempMerge values ("
first_time_through = True
DoCmd.SetWarnings False
While i < lstReportReferences.ListCount
strSQL = "insert into TempMerge values (" &
lstReportReferences.ItemData(i) & ");"
DoCmd.RunSQL strSQL
'If first_time_through Then
' strSQL = strSQL & lstReportReferences.ItemData(i)
' first_time_through = False
'Else
' strSQL = strSQL & "," & lstReportReferences.ItemData(i)
' End If
i = i + 1
Wend
DoCmd.SetWarnings True
'strSQL = strSQL & ";"
'DoCmd.RunSQL strSQL
Call MergeIt
End Sub
I got this from the Microsoft website sometime ago and it was modified by
someone who knows what they are doing. My basic question is why does this no
longer work? I've checked the path name of the Word document and it's
correct, I really can't figure this one out.
If anyone can help I would be grateful
records to a word document that's already created. This worked fine when my
database was in Access '97 but we've upgraded to Access 200 and now it
doesn't work. I keep getting told that there's an error and that the object
isn't defined.
This is my merging code;
Private Sub MergeIt()
Dim objWord As Word.Document
Set objWord =
GetObject("\\UM-UABSYS\Literature\LitLists\RefListMergeTemplate.doc",
"Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource
Name:="\\S:\UM-LABSYS\Literature\LitLists\LiteratureList_XP.mdb", _
LinkToSource:=True, Connection:="TABLE TempMerge",
SQLStatement:="SELECT References.Author, References.Year, References.Title,
References.[Publisher_Report_to], References.[In], References.Journal,
References.Volume, References.Edition, References.Pages FROM References,
TempMerge WHERE References.ID = TempMerge.ref_id"
objWord.MailMerge.Execute
End Sub
Private Sub cmdMerge_Click()
Dim i As Integer
Dim strSQL As String
Dim first_time_through As Boolean
i = 1
'delete previous records
DoCmd.RunSQL "delete * from TempMerge"
'strSQL = "insert into TempMerge values ("
first_time_through = True
DoCmd.SetWarnings False
While i < lstReportReferences.ListCount
strSQL = "insert into TempMerge values (" &
lstReportReferences.ItemData(i) & ");"
DoCmd.RunSQL strSQL
'If first_time_through Then
' strSQL = strSQL & lstReportReferences.ItemData(i)
' first_time_through = False
'Else
' strSQL = strSQL & "," & lstReportReferences.ItemData(i)
' End If
i = i + 1
Wend
DoCmd.SetWarnings True
'strSQL = strSQL & ";"
'DoCmd.RunSQL strSQL
Call MergeIt
End Sub
I got this from the Microsoft website sometime ago and it was modified by
someone who knows what they are doing. My basic question is why does this no
longer work? I've checked the path name of the Word document and it's
correct, I really can't figure this one out.
If anyone can help I would be grateful