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. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,947
    Thanks
    0
    Thanked 204 Times in 185 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]

  3. #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>

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,947
    Thanks
    0
    Thanked 204 Times in 185 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
  •