Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    May 2001
    Location
    Maryland, USA
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening an Excel File from Access (2000)

    I need help with this one. I'm trying to, in one click of a button, run a query and then open an Excel spreadsheet linked to the data from that make table query. This is what I have so far that runs the query. Is there an easy way to get this to open the spreadsheet after it's finished making the table?

    Thanks much,
    Eric

    Private Sub btnqryChart_Click()
    On Error GoTo Err_btnqryChart_Click

    Dim stDocName As String

    stDocName = "qryChart"
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryChart"
    DoCmd.SetWarnings True

    Exit_btnqryChart_Click:
    Exit Sub

    Err_btnqryChart_Click:
    MsgBox Err.Description
    Resume Exit_btnqryChart_Click

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Opening an Excel File from Access (2000)

    A relatively easy way to open an Excel workbook is

    Application.FollowHyperlink "C:ExcelMyWorkbook.xls"

    with the appropriate path and file name substituted. Another way is to use the ShellExecute API function. If you search for ShellExecute, you'll find several examples, e.g. <post#= 320106>post 320106</post#>.

  3. #3
    2 Star Lounger
    Join Date
    May 2001
    Location
    Maryland, USA
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening an Excel File from Access (2000)

    Fantastic! The FollowHyperlink works.

    Thank you very much,
    Eric

Posting Permissions

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