This is a note for my self when learning the VBA Access. I will show you how to open an Excel file (.xlsx) from Microsof Access Form using VBA. Its not hard to open a Microsoft Excel using VBA from MS Access.
First, we need to add Excel Object library first. To do this, go to Tools | References and look for Microsoft Excel 15.0 ObjectLibrary. Enable it and press OK.
Now we need to create the following code:
Dim AppExcel as Excel.Application Dim MyWorkbook as Excel.Workbook Set AppExcel = CreateObject("Excel.Application") Set MyWorkbook = AppExcel.Workbooks.Open("D:\test.xlsx") AppExcel.Visible = True Set AppExcel = Nothing Set MyWorkbook = Nothing
The code above will open file located in “D:\test.xlsx”