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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
*****

Is Excel loaded on the server?
 
Or is the user account running ASP.NET app (ASPNET/Network Service) allowed
to run Excel on the server?
 
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

Norman Yuan said:
Or is the user account running ASP.NET app (ASPNET/Network Service) allowed
to run Excel on the server?
 
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






Steve C. Orr said:
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


Mark said:
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
 
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


Mark said:
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






Steve C. Orr said:
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


Mark said:
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
 
Back
Top