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,707 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
Comment Utility
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
Comment Utility
Still not working.
0
 
LVL 3

Accepted Solution

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


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

11 Experts available now in Live!

Get 1:1 Help Now