Re: VB.NET/Excel Automation Issue-Cannot create ActiveX component.


G

George

By default ASP.NET account does not have permissions to run an applications like Excel, ...

You must give it using dcomcnfg.exe

Run dcomcnfg.exe and then go to Default Security and let ASPNET account to "Deffault launch" and "Default Access"

George
My Site - Body Jewelry
Hi,

What am I doing wrong? I created a ASP.NET web application using .NET (Visual Studio 2003) . I am running VB.NET on Windows XP with Excel 2002 also installed on the same machine.

I am getting the following error

System.Exception: Cannot create ActiveX component.

I have following references along with the default ones in my solution

Excel
Microsoft.Office.Core
Microsoft.VisualBasic
Office
System
VBIDE

I copied the following code from MSDN and made some changes to it...here is the code

Sub TestExcel()

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp =
CreateObject("Excel.Application","\\localhost")
xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)

xlSheet.Cells(2, 2) = "This is column B row 2"
xlSheet.Application.Visible = True
xlSheet.SaveAs("C:\Test.xls")
xlApp.Quit()
xlApp = Nothing

End Sub

I mean what am I doing wrong? I even opened MS Excel first and then ran this code...didn't work. I copied the GetExcel and DetectExcel from MSDN into my
code...that didn't work...and yes I tried even with Excel open and GetExcel and DetectExcel in place...not working. Searched on the web...and tried everything
they said...cannot get this thing to work.

I am getting the error "System.Exception: Cannot create ActiveX component." where it says xlApp = CreateObject("Excel.Application","\\localhost"). Any help for the above code will be greatly appreciated.

Thanks,
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top