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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Open .xls file from Access (2000 SP-3)

    Author
    Topic
    #436486

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1034966

      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)

      • #1034971

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

    Viewing 0 reply threads
    Reply To: Reply #1034966 in Open .xls file from Access (2000 SP-3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel