2

My code, running in MS Access 2010:

Sub test()
    Dim xl as Object
    set xl = CreateObject("Excel.Application")
End Sub

For whatever reason I am getting the error

ActiveX component can't create object.

I don't know why -- I go to Tools -> References and I even add the Microsoft Excel library, but still nothing.

7
  • 1
    Did you try any of the solutions posted here stackoverflow.com/questions/656934/… Commented Oct 26, 2017 at 15:36
  • I don't think any of those solutions apply to this specific scenario -- this code works from the MS Access .mdb databases but not the newer .accdb ones. Commented Oct 26, 2017 at 15:38
  • Can you do Dim xl As New Excel.Application? Commented Oct 26, 2017 at 15:38
  • @ErikvonAsmuth Yes but that's only because I went back and included the reference (Early binding I believe), the late binding is not working though as per the original post Commented Oct 26, 2017 at 15:39
  • The code works fine from .accdb database (used 2013 access) Commented Oct 26, 2017 at 15:41

1 Answer 1

3

Sometimes creating objects and not releasing them when you're finished can get things fouled up. Check your Task Manager and see if there are multiple "excel.exe" tasks running. Also note by default when they are created, they do not become visible unless you set the property after instantiating the object variable.

Sometimes rebooting the PC and trying this first will work. If it works after a fresh reboot, then stops working, something's not getting released properly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.