none
Open excel file by using VBA code from MS. Access

    Question

  • Please help, how to open excel file from VBA code of Ms. Access and run the macro that saved in that excel file.

    Thank you.
    • Moved by Martin Xie - MSFT Tuesday, October 20, 2009 9:03 AM Move it to VBA forum for better support. (From:Visual Basic General)
    Friday, October 16, 2009 8:08 AM

Answers

  • Hey, there,

    Function lixiang()
    Dim XL As Object
    Set XL = CreateObject("Excel.Application")
    XL.Workbooks.Open Application.CurrentProject.Path & "\lixiang.xls"
    XL.Run "Module1.killer"
    XL.ActiveWorkbook.Save
    XL.Application.Quit
    Set XL = Nothing
    End Function

    Notice:
    killer is the macro name in Excel, it is in module1.
    lixiang.xls is the file I am using.

    This will definitely work since I tested this on Access2007/2003+Excel2007/2003. Good luck, man~~~
    Li Xiang UNL Actuarial Science Student Access/ Excel/ SAS /SQL SAS is torturing me~~~ Still looking for a summer intern~~~ Anyone wants to hire me????~~~~
    • Marked as answer by Tim Li Friday, October 23, 2009 2:44 AM
    Tuesday, October 20, 2009 11:27 PM

All replies

  • Please help, how to open excel file from VBA code of Ms. Access and run the macro that saved in that excel file.

    Thank you.

    This is the VB.NET forum.  For help with VBA, visit the link below and find the VBA forum:

    For VBA, Office (VSTO), Macros and VBScript Questions


    :)



    Doug

    SEARCH ... then ask
    • Proposed as answer by NegativeX69 Friday, October 16, 2009 12:58 PM
    Friday, October 16, 2009 9:09 AM
  • You can provide a hyperlink in the MS Access form to open the Excel file or you can use the file open method of Scripting.FileSystemObject
    Tuesday, October 20, 2009 3:08 PM
  • Hey, there,

    Function lixiang()
    Dim XL As Object
    Set XL = CreateObject("Excel.Application")
    XL.Workbooks.Open Application.CurrentProject.Path & "\lixiang.xls"
    XL.Run "Module1.killer"
    XL.ActiveWorkbook.Save
    XL.Application.Quit
    Set XL = Nothing
    End Function

    Notice:
    killer is the macro name in Excel, it is in module1.
    lixiang.xls is the file I am using.

    This will definitely work since I tested this on Access2007/2003+Excel2007/2003. Good luck, man~~~
    Li Xiang UNL Actuarial Science Student Access/ Excel/ SAS /SQL SAS is torturing me~~~ Still looking for a summer intern~~~ Anyone wants to hire me????~~~~
    • Marked as answer by Tim Li Friday, October 23, 2009 2:44 AM
    Tuesday, October 20, 2009 11:27 PM