S
Slartibartfast
Hi all
I have a set of macros designed in Word 2000 to do automated Mail
Merges from a SQL server database via ODBC. They work very well at the
moment. These now need to be ported to Word 2003, however, I cannot
seem to get the OpenDataSource command to connect to a datasource in
Word 2002/3. The old code left the name field blank and used a system
DSN which no longer seems to be allowed.
The new code I obtained by recording a test macro - but it only
partially works. If I manually connect the document to the data source
before running the macro then it runs okay, if I don't manually
connect it always fails on the OpenDataSource line. This is
unacceptable since the system needs to run without any intervention.
Any ideas why this OpenDataSource fails to actually connect to the
data source? It's driving me nuts.
New Connect:
ActiveDocument.MailMerge.OpenDataSource Name:= _
"Q:\live\DataSources\Affinis.odc", _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Provider=MSDASQL.1;Persist Security Info=True;Extended
Properties=""DSN=Affinis1;Description=Affinis1;UID=Administrator;APP=Microsoft
Office XP;WSID=IPCDEVELOPER;DATABASE=Affinis;Trusted_Connection=Yes"";Initial
Catalog=Affinis", _
SQLStatement:="SELECT * FROM ""IPCTestView"" where
CorrespondenceItemID=324805", _
SQLStatement1:="", _
SubType:=wdMergeSubTypeOther
Old Connect (word 2000):
ActiveDocument.MailMerge.OpenDataSource Name:="", _
Connection:="DSN=affinis1;", _
SQLStatement:=MergeSQL$
Any help gratefully received.
I have a set of macros designed in Word 2000 to do automated Mail
Merges from a SQL server database via ODBC. They work very well at the
moment. These now need to be ported to Word 2003, however, I cannot
seem to get the OpenDataSource command to connect to a datasource in
Word 2002/3. The old code left the name field blank and used a system
DSN which no longer seems to be allowed.
The new code I obtained by recording a test macro - but it only
partially works. If I manually connect the document to the data source
before running the macro then it runs okay, if I don't manually
connect it always fails on the OpenDataSource line. This is
unacceptable since the system needs to run without any intervention.
Any ideas why this OpenDataSource fails to actually connect to the
data source? It's driving me nuts.
New Connect:
ActiveDocument.MailMerge.OpenDataSource Name:= _
"Q:\live\DataSources\Affinis.odc", _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Provider=MSDASQL.1;Persist Security Info=True;Extended
Properties=""DSN=Affinis1;Description=Affinis1;UID=Administrator;APP=Microsoft
Office XP;WSID=IPCDEVELOPER;DATABASE=Affinis;Trusted_Connection=Yes"";Initial
Catalog=Affinis", _
SQLStatement:="SELECT * FROM ""IPCTestView"" where
CorrespondenceItemID=324805", _
SQLStatement1:="", _
SubType:=wdMergeSubTypeOther
Old Connect (word 2000):
ActiveDocument.MailMerge.OpenDataSource Name:="", _
Connection:="DSN=affinis1;", _
SQLStatement:=MergeSQL$
Any help gratefully received.