Hi Reiner,
I just did a quick test and it works fine, here. Note,
however, that it may not be enough to have only the Name
and Subtype arguments. You should record a macro to see
what might be missing. Here's what I got (modified to use
the wdMergeSubTypeWord2000 enum), note the "Connection"
argument:
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Documents and Settings\xxx\My
Documents\SalesData.xls", _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="Entire
Spreadsheet", SQLStatement _
:="", SQLStatement1:="",
SubType:=wdMergeSubTypeWord2000
Note that I am assuming you're doing this in Word and not
another programming environment. And if the latter, that
you do have a reference set to the Word object library. I
do find the error message "Type mismatch" rather odd...
> tried using the SubType argument but when I
> try to open the data source with the following code:
[quoted text clipped - 7 lines]
> METHOD/PROPERTYGET "OpenDataSource" argument "SubType".
> Do you have an idea what could have gone wrong?
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
Reiner - 21 Jan 2004 12:35 GMT
Hi Cindy,
last night I did a lot of testing and came up with a version that
works: In another article in this group somebody posted that in
addition to Name and Connection at least SQLStatement is needed. After
changing my code to:
ActiveDocument.MailMerge.OpenDataSource
Name:="C:\Temp\Conditions.xls", _
Connection:="Sheet1$", _
SQLStatement:="SELECT * FROM `Sheet1$`"
everything works! From your other posts I do think that I now use
another method to connect to Excel, not DDE anymore since I do not use
the SubType parameter. Is this correct and do you have an idea if this
could still work with Word 2000?
Thanks for your help and patience!
Best regards,
Reiner Buehl.
Cindy M -WordMVP- - 21 Jan 2004 20:17 GMT
Hi Reiner,
> last night I did a lot of testing and came up with a version that
> works: In another article in this group somebody posted that in
[quoted text clipped - 10 lines]
> the SubType parameter. Is this correct and do you have an idea if this
> could still work with Word 2000?
ah, yes, in that case you've got an OLE DB connection. Looking at the
code you post, I'm *guessing* it could work in Office 2000 to generate a
DDE connection, but you'd need to test to be sure.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)