Automation Error Library Not Registered

ilfocorp
ilfocorp used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Karrtik IyerSoftware Architect

Commented:
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

Author

Commented:
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

Author

Commented:
Thanks Karrtik, but I am trying to open the excel file from Access 2010 vba.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Take a look at this, which requires registry edits.

Also, instead of this...

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

...try just this, which does the same thing...

     Dim xlApp As New Excel.Application

Wayne
Karrtik IyerSoftware Architect

Commented:
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
Most Valuable Expert 2012
Top Expert 2014

Commented:
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.

Author

Commented:
Excellent.  Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial