Open Excel sheet from Access


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Open Excel sheet from Access

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Open Excel sheet from Access

    [Originally posted by Jack]

    I want to open a specific excel file from a command button on an Access 97 form, I would be grateful for any advice. Thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Open Excel sheet from Access

    [Originally posted by Santiago Linero]

    A way to do it is using "Shell"

    Shell ("excel.exe <complete path to file>.xls")

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Open Excel sheet from Access

    [Originally posted by Jack]

    I hate to sound thick but I am quite new to vba, due you think you could give me an example??? cheers Jack

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Open Excel sheet from Access

    [Originally posted by Santiago Linero]

    All right, you've got your Command Button in Access 97, and you're in design view. Right-click the button and select "Event" tag, "on-click" option. There you click the "..." button and the form code should appear. The code you need is:

    Private Sub Command8_Click()
    On Error GoTo Err_Command8_Click

    Dim oApp As Object

    Shell ("excel.exe C:\XX\Numbers.xls")

    Exit_Command8_Click:
    Exit Sub

    Err_Command8_Click:
    MsgBox Err.Description
    Resume Exit_Command8_Click

    End Sub


    Replace Command8 with your button name and the path and file name with yours.

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Re:Open Excel sheet from Access

    [Originally posted by Jack]

    Cheers, thanks a lot I will give that a go. Jack

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center