Link to home
Start Free TrialLog in
Avatar of ilfocorp
ilfocorp

asked on

Automation Error Library Not Registered

Hello.  I have Office 2010 and am trying to open an excel file in vba.  I get the attached error.  Can someone help me with resolving it.

Private Sub cmdOpen_Click()

    Dim xlApp As Excel.Application
    Set xlApp = CreateObject("Excel.Application")

    xlApp.Visible = True


ERROR:
Automation error
Library not registered
    xlApp.Workbooks.Open "E:\DEVHELP\A\Abstract Reporting-Done\test\Template CoreAbsSum0915.xlsx", True, False
    Debug.Print xlApp.Version
    Set xlApp = Nothing
    xlApp.Quit


End Sub
Automation-Error_LibraryNotRegistere.doc
Avatar of Karrtik Iyer
Karrtik Iyer
Flag of India image

Instead can you try doing below in open click?
Workbooks.Open ("sales.xls")
After work is done
Workbooks("sales.xls").Close
http://www.excel-easy.com/vba/examples/close-open.html
Avatar of ilfocorp
ilfocorp

ASKER

Sorry guys.  I put the error in the middle of my script.  see  updated question below;

Hello.  I have Office 2010 and am trying to open an excel file in vba.  I get the attached error.  Can someone help me with resolving it.

 Private Sub cmdOpen_Click()

     Dim xlApp As Excel.Application
     Set xlApp = CreateObject("Excel.Application")

     xlApp.Visible = True
     xlApp.Workbooks.Open "E:\DEVHELP\A\Abstract Reporting-Done\test\Template CoreAbsSum0915.xlsx", True, False
     Debug.Print xlApp.Version
     Set xlApp = Nothing
     xlApp.Quit


 End Sub

ERROR:
 Automation error
 Library not registered
Thanks Karrtik, but I am trying to open the excel file from Access 2010 vba.
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok,
In your code we are trying to use COM  to open excel files. This error indicates that the COM interface we are trying create using create object is not found in the registry. This registry entries are created when the excel COM interop DLLs register themselves during installation, they can also be manually registered if we know the dll name. Try the solution that Wayne has suggested and get back to us if you still face some issues.
There is a good question on EE on the best way to do this in access using VBA, please see link below.
http://googleweblight.com/?lite_url=http://www.experts-exchange.com/questions/28380710/Opening-and-Closing-Excel-from-Access-in-VBA.html&ei=F3LQLF2E&lc=en-IN&s=1&m=497&ts=1449806112&sig=ALL1Aj739R3JnG_8z9yvjX0qIUVW78Nkkw
You're also mixing your bindings :)

If you're going to use Late Binding, then do this:

Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")

Many people use Early Binding during development, so you can have Intellisense, but then switch over to Late Binding on deployment to avoid issues like you describe.
Excellent.  Thank you.