Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Unanswered: Open Excel from Access

    Hi,
    Can anyone tell me what the VB commands are for opening a specific Excel file via an Access command button

    Regards
    John

  2. #2
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    first add a reference of Excel. then use this code on the click event of the command button

    Dim xlw As Excel.Workbook

    Set xlw = GetObject(strFile)
    xlw.Application.Visible = True

  3. #3
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Khan
    Thanks for the reply.

    This seems to fire up Excel OK but fails to load the required workbook, any idea way?

    This is my code

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "WeeklyCreditControl_qry1", acViewNormal
    DoCmd.SetWarnings True

    Dim xls As Excel.Workbook

    Set xls = GetObject("H:\RISTATS\Credit_Control\1096\credit control test.xls")
    xls.Application.Visible = True



    Regards
    John

  4. #4
    Join Date
    May 2004
    Posts
    9
    Why not add a 'FollowHyperlink' right below your Do.Cmd?

    This should do the trick:

    FollowHyperlink "H:\RISTATS\Credit_Control\1096\credit control test.xls"

  5. #5
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    I had a lot trouble trying to open Excel for a specific file and I think part of my trouble was using Access 95 and the code being posted up would not work for Access 95

    However, I found the easiest way to solve the problem (at least for me) was to create a shortcut and then have a macro do RunApp for a .bat file that ran the shortcut.

    Mike

  6. #6
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Thanks guy's for you suggestion, In the end I tried these suggestions and the Shell function but the FollowHyperLink idea seemed to work the best.

    Regards
    John

Posting Permissions

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