MS Access not able to open and assign Excel objects

356 views Asked by At

Excel file won't open in MS Access.

This piece of code was working until a few days ago. Now it's NOT erroring out and it's not creating any Excel objects.

Dim XL As Object
Set XL = New Excel.Application
XL.workbooks.Open(ourPath)

The Object assignment should work (the path is correct, I've checked it multiple times).

2

There are 2 answers

3
Lee Mac On

Since you are using early binding, perhaps you are missing the reference to the Microsoft Excel Object library (Tools > References), or perhaps this library has been rendered as MISSING as a result of opening your database in an earlier version of MS Access.

Nevertheless, to avoid the reliance on references entirely and rule this out as a possible cause, you could try using late binding e.g.:

Dim XL As Object
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open(ourPath)
0
user6879637 On

So what was happening was, the excel files had add-ins that were preventing for excel to be opened properly. The code worked like a charm as soon as those add-ins were disabled.