Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pulling data into Word from an Excel database

    In Word, I have some old code DAO code that reads signoff details (name, title & email address) from an Excel database:

    Set db = OpenDatabase(sSourceFile, False, True, "Excel 8.0")
    sSQL = "SELECT * FROM `Database`"
    Set rs = db.OpenRecordset(sSQL)

    This works fine as long as the spreadsheet is still in .xls format.

    If I update the spreadsheet to .xlsx format and change Excel 8.0 to Excel 12, 14 or 15, I get an error "Could not find installable ISAM".

    I know DAO is pretty old technology. Is there a better way to do it?

    V>

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,860
    Thanks
    0
    Thanked 179 Times in 165 Posts
    Is there a reason for not using mailmerge or a DATABASE field for this? A VBA alternative would be to use the MailMerge.OpenDataSource method
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #3
    New Lounger
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by macropod View Post
    Is there a reason for not using mailmerge or a DATABASE field for this? A VBA alternative would be to use the MailMerge.OpenDataSource method
    Thanks Paul. That's an interesting idea, but I prefer to prompt the user via a single dialog box as there are several choices involved (eg which office are they in? do they want to include a signature image?) I don't think mailmerge would help in that instance, or am I missing something?

    V>

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,860
    Thanks
    0
    Thanked 179 Times in 165 Posts
    If you drive a mailmerge via a macro, it's certainly possible to solicit all those details at the start (e.g. by employing a userform). Depending on what's in the data and how the mailmerge main document is configured, it may even be possible to solicit those details via a series of ASK and/or FILLIN fields in the mailmerge main document, without recourse to VBA.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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