R
ramudu
Hi,
We use mail merge in our application and for one our clients it is
throwing the above error while generating the mail merge document. This
happens when I invoke the OpenDataSource() method.
The code for opening the spreadsheet looks something like this:
Dim o As Object = Type.Missing
m_doc.MailMerge.OpenDataSource(m_strDsName, _
o, o, o, o, o, o, o, o, o, o, _
"Data", o, o, o,
Word.WdMergeSubType.wdMergeSubTypeWord2000)
where m_strDsName is the physical location of the document.
In my case, it is able to get data up to a certain number of rows after
which it starts to throw an error. I looked at the Microsoft support
website for the error,
http://support.microsoft.com/kb/196952
but this document doesn't help much in my case.
My Excel data source consists of one spreadsheet with one sheet called
Sheet1 and the columns are dynamically generated.
In some posts in this and other groups I've seen that DDE is not
reliable and using ODBC is encouraged. So I tried using an ODBC
connection and the code for the same looks like this.
Dim sConnection As String
sConnection = "DSN=Excel Files;DBQ=""" & m_strDsName &
"![Sheet1]"";DriverId=790;MaxBufferSize =2048;PageTimeout=5;"
m_doc.MailMerge.OpenDataSource(Name:=m_strDsName, _
ConfirmConversions:=False, OpenExclusive:=False, _
LinkToSource:=True, ReadOnly:=True, _
Format:=WdOpenFormat.wdOpenFormatAuto, _
Connection:=sConnection, _
SQLStatement:="SELECT * FROM 'Data",
SQLStatement1:="", _
SubType:=WdMergeSubType.wdMergeSubTypeWord2000)
This too throws an error 'Cannot establish connection to data source'.
Help! Thanks!
- Sri
We use mail merge in our application and for one our clients it is
throwing the above error while generating the mail merge document. This
happens when I invoke the OpenDataSource() method.
The code for opening the spreadsheet looks something like this:
Dim o As Object = Type.Missing
m_doc.MailMerge.OpenDataSource(m_strDsName, _
o, o, o, o, o, o, o, o, o, o, _
"Data", o, o, o,
Word.WdMergeSubType.wdMergeSubTypeWord2000)
where m_strDsName is the physical location of the document.
In my case, it is able to get data up to a certain number of rows after
which it starts to throw an error. I looked at the Microsoft support
website for the error,
http://support.microsoft.com/kb/196952
but this document doesn't help much in my case.
My Excel data source consists of one spreadsheet with one sheet called
Sheet1 and the columns are dynamically generated.
In some posts in this and other groups I've seen that DDE is not
reliable and using ODBC is encouraged. So I tried using an ODBC
connection and the code for the same looks like this.
Dim sConnection As String
sConnection = "DSN=Excel Files;DBQ=""" & m_strDsName &
"![Sheet1]"";DriverId=790;MaxBufferSize =2048;PageTimeout=5;"
m_doc.MailMerge.OpenDataSource(Name:=m_strDsName, _
ConfirmConversions:=False, OpenExclusive:=False, _
LinkToSource:=True, ReadOnly:=True, _
Format:=WdOpenFormat.wdOpenFormatAuto, _
Connection:=sConnection, _
SQLStatement:="SELECT * FROM 'Data",
SQLStatement1:="", _
SubType:=WdMergeSubType.wdMergeSubTypeWord2000)
This too throws an error 'Cannot establish connection to data source'.
Help! Thanks!
- Sri