Results 1 to 5 of 5

Thread: [RESOLVED] Word was unable to open datasource

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Resolved [RESOLVED] Word was unable to open datasource

    I use word automation (WordXP) in my vb6 app
    I want to open a datasource for my with MailMerge (i use this for my labels)


    VB Code:
    1. Appword.ActiveDocument.mailMerge.openDataSource Name:= FolderName  & "\FormInvullen.mdb", SQLStatement:="select * from LayoutTable", ReadOnly:=True

    I get error 'Word was unable to open the datasource'
    But i know i have the correct Folderpath in FolderName var
    and it can find the database FormInvullen.mdb

    When i only give the databasename

    VB Code:
    1. Appword.ActiveDocument.mailMerge.openDataSource Name:= FolderName  & "\FormInvullen.mdb"

    then i get a window where i can choose the table (with name LayoutTable) from a list.
    I allso tried leaving out the Readonly but now effect, what am i doing wrong it won't axcept my tablename for some reason.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Word was unable to open datasource

    Place a breakpoint before it executes it and place a Debug.Print FolderName & "\FormInvullen.mdb" and see if it prints to the immediate window with the correct path.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Re: Word was unable to open datasource

    I tried that and Databasename and tablename is correct.
    Like i mentioned before he does find my databasename, but he wont accept my tablename i set through the SQLStatement par (although i copied the exact tablename from my access database). I got stuck here

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Word was unable to open datasource

    Place the entire path in a variable instead of making word concatenate them together.

    You also may need to specify the Connection type as either Table tablename or Query queryname.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Re: [RESOLVED] Word was unable to open datasource

    So i had to put Table in front of the tablename
    Thx for the solution one problem solved, works like a charme

    I gladly mark this resolved.

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