Solved

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Posted on 2007-03-30
3
1,714 Views
Last Modified: 2008-01-09
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Public Function LoadExcelSheet(ByVal dt As DataTable)
        Try
            Dim xlWorkBook As Excel.Workbook
            Dim xlWorkSheet As Excel.Worksheet

 ****           xlWorkBook = New Excel.Application().Workbooks.Add(Missing.Value)  ***** fails on this line
            xlWorkBook.Application.Visible = True
            xlWorkSheet = xlWorkBook.ActiveSheet

           
            xlWorkSheet.Visible = True
            xlWorkSheet.Minimum = 1
            xlWorkSheet.Maximum = dt.Rows.Count + 1
            xlWorkSheet.Value = 1
            ' This is to access the first work sheet of your application
            xlWorkSheet = CType(xlWorkBook.Worksheets(1), Excel.Worksheet)
            xlWorkSheet.Name = "SampleExcel"
            For i As Integer = 1 To dt.Rows.Count
                For j As Integer = 1 To dt.Columns.Count
                    ' This is to add the Data which retrieved from
                    ' the database into your Excel Sheet.
                    CType(xlWorkSheet.Cells(i, j), Excel.Range).Value2() = dt.Rows(i - 1).ItemArray(j - 1).ToString()

                    'dt.Rows[i-1].ItemArray[j-1].ToString()--> This will retrieve
                    ' data from your datatable's
                    '(i-1)th rows (j-1)st column
                Next
                xlWorkSheet.Value = xlWorkSheet.Value + 1
            Next
            '  MessageBox.Show("Your Process Completed Successfully")
            xlWorkSheet.Visible = False
        Catch e1 As Exception
            '  MessageBox.Show(e1.Message)
        End Try


    End Function

0
Comment
Question by:mathieu_cupryk
  • 2
3 Comments
 
LVL 3

Expert Comment

by:Nico
ID: 18823149
I'm quite sure this happens because of a COM+ permission problem.. as in the framework has no access to the COM object. There is lots of info about this on the web.. You might find your answer here: http://www.codeguru.com/forum/printthread.php?t=383912&page=3&pp=15
0
 

Author Comment

by:mathieu_cupryk
ID: 18823929
Still not working.
0
 
LVL 3

Accepted Solution

by:
Nico earned 500 total points
ID: 18824033
There's a MS article for office automation here that you could check: http://support.microsoft.com/kb/257757/EN-US/


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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