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

Discussion in 'ASP .Net' started by George, Jun 25, 2004.

  1. George

    George Guest

    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
    "Abdullah Haroon Imam" <> wrote in message news:...
    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,
     
    George, Jun 25, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. W. Broersen
    Replies:
    2
    Views:
    6,888
    W. Broersen
    Jan 21, 2004
  2. Peter O'Reilly
    Replies:
    6
    Views:
    55,999
    rayuusuke34
    Aug 25, 2009
  3. Ken Cox [Microsoft MVP]

    Re: Cannot Create ActiveX component

    Ken Cox [Microsoft MVP], Jun 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    3,346
    Ken Cox [Microsoft MVP]
    Jun 1, 2004
  4. Trevor Benedict R
    Replies:
    0
    Views:
    459
    Trevor Benedict R
    Jun 27, 2004
  5. Steve Kershaw
    Replies:
    4
    Views:
    6,862
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 17, 2007
Loading...

Share This Page