Results 1 to 3 of 3

Thread: [RESOLVED] Mailmerge openDataSoure opens a Select table prompt window

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Resolved [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.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. ActiveDocument.MailMerge.OpenDataSource Name:= _
    2.         "\\Mistiplace\mis docs\bsb.mdb", ConfirmConversions:=False, ReadOnly:= _
    3.         False, LinkToSource:=True, AddToRecentFiles:=False, PasswordDocument:="", _
    4.          PasswordTemplate:="", WritePasswordDocument:="", WritePasswordTemplate:= _
    5.         "", Revert:=False, Format:=wdOpenFormatAuto, Connection:= _
    6.         "DSN=MS Access Database;DBQ=\\Mistiplace\mis docs\bsb.mdb;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" _
    7.         , SQLStatement:="SELECT * FROM `bsb`", SQLStatement1:=""

    it seems to need both the connection and sqlstatement to work, some of the stuff can be discarded

    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    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:
    1. Dim tkFile as string
    2. tkFile = FolderName  & "\FormInvullen.mdb"
    3. Appword.ActiveDocument.mailMerge.openDataSource Name:= tkFile,
    4. Connection:="DSN=MS Access Database;DBQ=" & tkFile & ";FIL=MS Access;",
    5. 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width