I think you can ignore all the parameters except Name (which you have) and
SQLStatement, which needs to be set to a string containing a SQL SELECT
statement, e.g.
"SELECT * FROM `Sheet1$`"
I would've tried to use a few more parms with OpenDataSource but I haven't for the life
of me been able to find out what I'm required to pass.
Yes, it's difficult to find out what is needed to make these connections.
If you record a Word macro then make the connection, you may be able to see
the (VBA) macro code that Word generates. However, that may not work in Word
2002 as there are some problems, and you may also find that you cannot
display the values of
ActiveDocument.MailMerge.DataSource.ConnectionString and .QueryString
However, if you set up the connection, then save the document as HTML, then
open it in Notepad, you should be able to see the values of the various
parameters fairly near the top of the file.
The other parameters you may need to set are
Connection (but you can probably set this to "")
SubType - here it is set to wdMergeSubTypeAccess, which has value 1. You
might think that is odd because you are opening an Excel file, but it
probably reflects the fact that the Jet OLEDB provider is being used to read
the spreadsheet.
In my experience, none of the other parameters (other than SQLStatement1
which you only need if your SQL needs to be quite long) has any noticeable
effect
--
Peter Jamieson
RHNewbie said:
My code is in Visual FoxPro but you should get the idea of what I'm doing.
oWord = createobject("Word.Application")
oWord.Documents.Add()
oWord.Visible = .T.
oWord.ActiveDocument.MailMerge.OpenDataSource("c:\temp\datasource.xls")
I also tried the following (before oWord.Visible = .T.): oWord.DisplayAlerts = .F.
From the code, you can see that my datasource is an Excel file on my local drive.
I would've tried to use a few more parms with OpenDataSource but I haven't
for the life of me been able to find out what I'm required to pass. The
intellisense tells me that the second parm is Format type Variant, but I
have no idea what "Format" is supposed to be. The next parm after Format is
ConfirmConversions. That may help in suppressing the window but
OpenDataSource doesn't like that second parm being blank.