简体   繁体   中英

ActiveX component can't create object Excel.Application

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM