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,708 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

23 Experts available now in Live!

Get 1:1 Help Now