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

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
 
L

Lucas Tam

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?
 
N

Norman Yuan

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

Steve C. Orr [MVP, MCSD]

G

Guest

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?
 
G

Guest

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




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
 
S

Steve C. Orr [MVP, MCSD]

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




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




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
 

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

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top