Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Sep 2006
    Location
    Jhongli, Taiwan
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open .xls file from Access (2000 SP-3)

    The following command button code opens an instance of Excel. But how can it also open a specific file at the same time?

    Private Sub cmdSpread_Click()
    On Error GoTo Err_cmdSpread_Click

    Dim oApp As Object

    Set oApp = CreateObject("Excel.Application")
    oApp.Visible = True

    'Only XL 97 supports UserControl Property
    On Error Resume Next
    oApp.UserControl = True

    Exit_cmdSpread_Click:
    Exit Sub

    Err_cmdSpread_Click:
    MsgBox Err.Description
    Resume Exit_cmdSpread_Click

    End Sub

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

    Re: Open .xls file from Access (2000 SP-3)

    Add the following at the beginning of the code:

    Dim oWbk As Object

    and this after the line Set oApp = ...:

    Set oWbk = oApp.Workbooks.Open("C:ExcelMyWorkbook.xls")

    (substituting the correct path and filename, of course)

  3. #3
    Lounger
    Join Date
    Sep 2006
    Location
    Jhongli, Taiwan
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open .xls file from Access (2000 SP-3)

    Hans,
    You're the best!
    Thank you as always.
    Brady

Posting Permissions

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