Asp.Net >> VB.Net (in ASP.Net) won't create instance of Excel

by TWFyaw » Thu, 11 Aug 2005 05:36:19 GMT

I was able to get procedure to work in a VB.Net Windows application, and want
to get it to work within a ASP.Net page. It won't create the instance of
Excel. It blows up on the CreateObject class.

What am I missing?

Code, Error and Stack info are as follows:

Code:
Dim xlApp As Microsoft.Office.Interop.Excel.Application
xlApp = CreateObject("Excel.Application") '**** Blows-up here *****

Error Exception Details:
System.Exception: Cannot create ActiveX component.

Stack Trace:
[Exception: Cannot create ActiveX component.]
Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String
ServerName)
ReserveDB.WebForm1.btCreateDB_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\ReserveDB\WebForm1.aspx.vb:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()


Thanks, Mark


Asp.Net >> VB.Net (in ASP.Net) won't create instance of Excel

by Lucas Tam » Thu, 11 Aug 2005 05:38:49 GMT


"=?Utf-8?B?TWFyaw==?=" < XXXX@XXXXX.COM > wrote in



Is Excel loaded on the server?

--
Lucas Tam ( XXXX@XXXXX.COM )
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Asp.Net >> VB.Net (in ASP.Net) won't create instance of Excel

by Norman Yuan » Thu, 11 Aug 2005 07:48:32 GMT

Or is the user account running ASP.NET app (ASPNET/Network Service) allowed
to run Excel on the server?








Asp.Net >> VB.Net (in ASP.Net) won't create instance of Excel

by Steve C. Orr [MVP, MCSD] » Thu, 11 Aug 2005 12:12:30 GMT

Microsoft (and I) recommend not using COM Interop with Microsoft Office
products from an ASP.NET web page. Excel was not designed to be used in
this way. If you're determined to do it anyway, these articles gives you
the ins and outs along with some better alternatives:

http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx

And here's a good 3rd party component you could use:
http://www.aspose.com/Products/Aspose.Excel

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net








Asp.Net >> VB.Net (in ASP.Net) won't create instance of Excel

by TWFyaw » Fri, 12 Aug 2005 07:57:03 GMT

Norman -

Two questions:
What do I have to do to allow Excel to be opened by ASP.Net?

(per your comment to my similar posting on dotnet.general) How do I
cross-post?

Thank you for your comments.

Mark








Asp.Net >> VB.Net (in ASP.Net) won't create instance of Excel

by TWFyaw » Fri, 12 Aug 2005 08:04:02 GMT

Steve -

Thanks for your comments.

All I am trying to do is open an existing Excel workbook and execute a VBA
procedure contained in the workbook. And then close the workbook. I'm
really using ASP.Net (with VB) as a controller/wrapper. No biggie.

ASP.Net returns an error when I try to open the Excel instance (see error
message below). Is it a security issue? If so how can I fix it?

Thanks, Mark












Asp.Net >> VB.Net (in ASP.Net) won't create instance of Excel

by Steve C. Orr [MVP, MCSD] » Fri, 12 Aug 2005 08:35:03 GMT

Yes, it is a security issue, which I've covered fairly thoroughly here:
http://SteveOrr.net/articles/ExcelExport.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net











Similar Threads

1. VB.Net (in ASP.Net) won't create instance of Excel

I was able to get procedure to work in a VB.Net Windows application, and want 
to get it to work within a ASP.Net page.  It won't create the instance of 
Excel.  It blows up on the CreateObject class.

What am I missing?

Code, Error and Stack info are as follows:

Code:
        Dim xlApp As Microsoft.Office.Interop.Excel.Application
        xlApp = CreateObject("Excel.Application")  '**** Blows-up here *****

Error Exception Details: 
    System.Exception: Cannot create ActiveX component.

Stack Trace: 
   [Exception: Cannot create ActiveX component.]
   Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String 
ServerName)
   ReserveDB.WebForm1.btCreateDB_Click(Object sender, EventArgs e) in        
       c:\inetpub\wwwroot\ReserveDB\WebForm1.aspx.vb:40
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
      
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler 
sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()

 
Thanks, Mark