Reputation: 41
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).
Upvotes: 0
Views: 528
Reputation: 41
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.
Upvotes: 0
Reputation: 16025
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)
Upvotes: 0