VBA & Macro Problems

Open Excel from Access VBA Without Reference Errors

John WilsonJohn Wilson Nov 13, 2026 870 views

Question details

Open an Excel workbook from Access VBA without a user-defined type compilation error.

How to Open Excel from Access VBA Without Reference Errors
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA module

In Access, press Alt+F11 and open the module containing your Excel automation code, or select Insert > Module to create one.

2
Declare objects and open the workbook

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

3
Compile and run the procedure

In the VBA editor, select Debug > Compile, then place the cursor inside OpenExcelWorkbook and press F5. Excel should open the specified workbook.

Use late binding to open Excel without an object library reference
Review Excel-specific constants: Without the Excel reference, named Excel constants such as xlUp may be unavailable. Define the constants you need or use their documented numeric values. The example leaves Excel open for you to use.
Free Microsoft Office alternative

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.

Open and edit spreadsheets in a familiar interfaceCompatible with Microsoft Excel formats such as XLSX and XLSFree, lightweight tools for everyday Office workMove existing Office files into WPS Office without starting over
microsoft office alternative - wps office

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.