P
Peter Carpenter
Hello everyone!
I'm trying to automate a mail merge into a Word 2000 document from
within Access 2000. The code I'm using is:
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oSel As Word.Selection
Dim appTitle As String
Dim setAccessCaption As Boolean
'Start Word and open the document template.
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
oDoc.Activate
oWord.Visible = True
MM.OpenDataSource Name:="", _
Connection:="DSN=CHdatabase;DATABASE=CHdata;", _
SQLStatement:=sqlstr
oDoc.MailMerge.Destination = wdSendToNewDocument
Set MailMerge2000 = oDoc.MailMerge
The value of sqlstr is "execute sp_groupIndHouseData 9, 1875" and this
format works fine for a number of other stored procedures I've got.
However, I have one stored procedure (which admittedly is a lot more
complicated and larger - about 160 columns / varying numbers of rows)
and everytime I try to run it I get an error message from 'Microsoft
Word' stating 'Word was unable to open the data source.'
The interesting thing is that I can open this stored procedure (again
using the same syntax) from msquery within a word document, and the
data shows beautifully. However, when I press return data to word,
the same error comes back.
My questions are, if anyone has any thoughts they'd like to share, are
there limitations on the number of columns allowed? Why would Msquery
be able to access the data but not word? What are the differences?
Thanks HEAPS in advance!!![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Peter Carpenter
I'm trying to automate a mail merge into a Word 2000 document from
within Access 2000. The code I'm using is:
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oSel As Word.Selection
Dim appTitle As String
Dim setAccessCaption As Boolean
'Start Word and open the document template.
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
oDoc.Activate
oWord.Visible = True
MM.OpenDataSource Name:="", _
Connection:="DSN=CHdatabase;DATABASE=CHdata;", _
SQLStatement:=sqlstr
oDoc.MailMerge.Destination = wdSendToNewDocument
Set MailMerge2000 = oDoc.MailMerge
The value of sqlstr is "execute sp_groupIndHouseData 9, 1875" and this
format works fine for a number of other stored procedures I've got.
However, I have one stored procedure (which admittedly is a lot more
complicated and larger - about 160 columns / varying numbers of rows)
and everytime I try to run it I get an error message from 'Microsoft
Word' stating 'Word was unable to open the data source.'
The interesting thing is that I can open this stored procedure (again
using the same syntax) from msquery within a word document, and the
data shows beautifully. However, when I press return data to word,
the same error comes back.
My questions are, if anyone has any thoughts they'd like to share, are
there limitations on the number of columns allowed? Why would Msquery
be able to access the data but not word? What are the differences?
Thanks HEAPS in advance!!
Peter Carpenter