[RESOLVED] Mailmerge openDataSoure opens a Select table prompt window
I use word Automation in my VB6 application.
I get an annoying Select table Window/prompt with the list of my tables.
Although i give my tablename as a parameter
Code:
Appword.ActiveDocument.mailMerge.openDataSource Name:= FolderName & "\FormInvullen.mdb", SQLStatement:="Table LayoutTable", ReadOnly:=True
Now this works perfect in Word2002 but in earlier version Word2000
I allways get the 'Select table window displayed'.
Now i have read the folowing article at microsoft
http://support.microsoft.com/kb/q289830/
And i tried Connection instead of SQLStatement but did not help.
Code:
Appword.ActiveDocument.mailMerge.openDataSource Name:= FolderName & "\FormInvullen.mdb", Connection:="Table LayoutTable", ReadOnly:=True
I allso added SQLstatment allso but with no effect.
Can someone help me.
Re: Mailmerge openDataSoure opens a Select table prompt window
i tried your code and got the same problem you did, but this seems to fix it
VB Code:
ActiveDocument.MailMerge.OpenDataSource Name:= _
"\\Mistiplace\mis docs\bsb.mdb", ConfirmConversions:=False, ReadOnly:= _
False, LinkToSource:=True, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", WritePasswordDocument:="", WritePasswordTemplate:= _
"", Revert:=False, Format:=wdOpenFormatAuto, Connection:= _
"DSN=MS Access Database;DBQ=\\Mistiplace\mis docs\bsb.mdb;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" _
, SQLStatement:="SELECT * FROM `bsb`", SQLStatement1:=""
it seems to need both the connection and sqlstatement to work, some of the stuff can be discarded
pete
Re: Mailmerge openDataSoure opens a Select table prompt window
Thx for your reply.
I already tested your approach using ODBC/DSN, and indead this seems to work.
VB Code:
Dim tkFile as string
tkFile = FolderName & "\FormInvullen.mdb"
Appword.ActiveDocument.mailMerge.openDataSource Name:= tkFile,
Connection:="DSN=MS Access Database;DBQ=" & tkFile & ";FIL=MS Access;",
SQLStatement:="Table LayoutTable", ReadOnly:=True
This seems to work. I allready tried on 2 PC's with Word2000 and 1 pc with Word2002.
I am new to ODBC/DSN.
Does this ODBC is machine independent?
I noticed in Configarationscreen in Windows i have a shortcut i can open with ODBC data, there i can find the MS Access database. Is this allways available an alll PC's or should i check that.