Problem creating Excel file from VB.NET;   Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

Posted on 2009-12-17
Last Modified: 2013-11-26
I want to create excel worksheet from my VB.NET Project. I have searched & tried a code from web. I am developing in Visual studio 2008, using excel 2007, and added the nessasory referances to my project. The code does not show any error However, when executed, at the point of creating the workbook, runtime error occurs.

Error Message :
Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

what does this error mean and what is cure for it ?
Imports Excel = Microsoft.Office.Interop.Excel

Public Class ExcelTest

    Inherits System.Windows.Forms.Form

    Friend WithEvents Button1 As Button

    Public Sub New()


        Button1 = New Button

        With Button1

            .Location = CalcLocation(2, 10)

            .Size = CalcSize(1.5, 10)

            .Text = "TEST"

        End With


    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim xlApp As Excel.Application

        Dim xlWorkBook As Excel.Workbook

        Dim xlWorkSheet As Excel.Worksheet

        Dim misValue As Object = System.Reflection.Missing.Value

        xlApp = New Excel.ApplicationClass

        xlWorkBook = xlApp.Workbooks.Add(misValue)

        xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Excel.Worksheet)

        xlWorkSheet.Cells(1, 1) = ""







        MsgBox("Excel file created , you can find the file c:\")

    End Sub

    Private Sub releaseObject(ByVal obj As Object)



            obj = Nothing

        Catch ex As Exception

            obj = Nothing



        End Try

    End Sub

End Class

Open in new window

Question by:kkp01
    LVL 15

    Assisted Solution

    Verify that Excel is installed and version is not lower than that used to create the program.

    Author Comment

    Thanks for your help. Verified the versions mis-match. Error was solved.
    Now I used excel 2007 to create the program. Now the error disappeared. Previously I was using excel 2000, and XP files to create program.  
    DOES THAT MEAN THAT : program created by using files of excel 2000/XP , will not work if client's computer is having latest version of excel ????
    LVL 15

    Expert Comment

    Yes, it has forward compatibility only.
    LVL 15

    Expert Comment

    Sorry, in this case Forward compability must apply, but it is posible that broken on 2007 version.

    Author Comment

    Thanks for your comments. ONE LAST CLEARIFICATION needed.
    If I create program using excel 2000, and my clients are using office 2000, it is going to be ok. But if my clients upgrade to office 2007, then I will have to re-generate my program using excel 2007 files. BUT THEN WHAT HAPPENS to my other client who are not upgrading ?, are they forced to upgrade their office version ?.
    WHAT is way out to provide a common program to office 2000 users and office 2007 users ? . Because I can not force all my clients to upgrade, Will I have to maintain different different versions of my program according to excel versions....
    LVL 15

    Expert Comment

    You can create two librarys, one for office 2000 and the other for 2007.
    I do´nt understand the borken fordward compatibility.

    Accepted Solution

    I just want to make sure that if I am using office 2000 files to create my application which exports some data in excel sheet, and, such an application is running on a machine where office 2007 is installed.
    All I want to know is that, in such situation, will my application be able to create an worksheet on that machine and export data ?

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now