Open Excel from Access VBA Without Reference Errors
Question details
Open an Excel workbook from Access VBA without a user-defined type compilation error.

- Product
- Microsoft Access VBA and Microsoft Excel
- Device & OS
- not provided
- Scenario
- An Access VBA procedure needs to create an Excel application and open a workbook.
- Observed behavior
- Access displays the compile error “User-defined type not defined” when Excel object types are used without a valid Excel Object Library reference.
Confirm that desktop Excel is installed on the computer running the Access code, and identify the full path to the workbook you want to open. Open the Access database and press Alt+F11 to access the VBA editor.
Use late binding to open Excel without an object library reference
Use late binding when you want to avoid requiring a specific Excel Object Library reference in Access.
Late binding declares Excel variables as Object and creates Excel at runtime. It does not require an Excel Object Library reference, but desktop Excel must still be installed.
In Access, press Alt+F11 and open the module containing your Excel automation code, or select Insert > Module to create one.
Replace Excel-specific declarations such as Excel.Application and Excel.Workbook with Object declarations. For example, paste this procedure into the module and replace the path with your workbook path: Sub OpenExcelWorkbook() Dim appExcel As Object Dim myWorkbook As Object Set appExcel = CreateObject("Excel.Application") appExcel.Visible = True Set myWorkbook = appExcel.Workbooks.Open("C:\YourFolder\YourWorkbook.xlsx") End Sub
In the VBA editor, select Debug > Compile, then place the cursor inside OpenExcelWorkbook and press F5. Excel should open the specified workbook.

Enable the Microsoft Excel Object Library for early binding
Use early binding when you want to keep Excel-specific variable types and use VBA IntelliSense.
Work with Excel files in WPS Office
WPS Office is a free, lightweight alternative for opening and editing Office files in a familiar interface, making it easy to move everyday spreadsheet work from Microsoft Office. It does not fix Access VBA references or replace Access database automation.

Frequently Asked Questions
Why does Access say “User-defined type not defined” for Excel.Application?
The Excel Object Library reference may be missing or invalid. In the VBA editor, check Tools > References, or change Excel-specific declarations to Object and use CreateObject("Excel.Application").
Does late binding require Excel to be installed?
Yes. CreateObject("Excel.Application") creates an instance of the installed desktop Excel application. Late binding removes the VBA library reference requirement, not the need for Excel.
Will an early-bound Access database work with older Excel versions?
It depends on the available library and the Excel features your code uses. On each target computer, check Tools > References for a missing Excel library and test the procedure with that version.
How do I close Excel after an automated task?
If your code created the Excel instance and you want to close it, call myWorkbook.Close with the appropriate SaveChanges setting, then call appExcel.Quit. Set the workbook and application variables to Nothing afterward.




