grant IIS permission to create excel activex object

S

Steve Richter

I am getting error in a vbscript:
ActiveX component cant create object: Excel.Application.

The vbscript code is:
Dim objExcel
Set objExcel = CreateObject("Excel.Application")

I am pretty sure it is a permission issue because the script works when
I point the browser directly at the .htm file on the c: drive:
c:\inetpub\wwwroot\DemoSite\VbScriptTest.htm

What is the quickest, best way to grant the IIS user ( aspnet? )
permission to create the activex object in error?

thanks,
-Steve
 
E

Elton Wang

S

Steve Richter

Elton said:
Hi Steve,

First of all, it's better not to use Office automation on
server-side. Microsoft does not currently recommend, and
does not support, Automation of Microsoft Office
applications on server-side.
(http://support.microsoft.com/default.aspx?scid=kb;EN-
US;q257757#kb2)

Secondly, if you still want to use it, please check out
following url:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dno2k3ta/html/odc_VBNETcallsVBA.asp


HTH

Elton Wang
(e-mail address removed)

Hi Elton,

thanks for the reply. Yes, I have read those articles in the last few
days. The problem does not appear to be a permission issue because I
made ASPNET an administrator on my development system and the problem
remains.

Thinking about it, there should be no permission issues. I am not
using Excel on the server side. At least I dont think I am!

<script language="vbscript">
Sub exportbutton_onclick
Dim sHTML, oExcel, oBook
sHTML = document.all.item("DataGrid1").outerHTML
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oExcel.Visible = true
oExcel.UserControl = true
End Sub
</script>

This is all client side scripting, right? So whatever permission is
required should be a function of the client side IE user.

My problem remains and I still dont understand. My demo .htm file,
that runs the above script to copy a rendered <TABLE> to an excel
spreadsheet, works when I navigate to the .htm file via a c: drive
physical path:
c:\inetpub\wwwroot\DemoSite\VbScriptTest.htm

but it fails with the "ActiveX component cant create object:
Excel.Application" message when I navigate to it via:
http://localhost/demosite/VbScript1.htm

Why cant the ActiveX component create the object?

thanks,

-Steve
 
L

Lucas Tam

thanks for the reply. Yes, I have read those articles in the last few
days. The problem does not appear to be a permission issue because I
made ASPNET an administrator on my development system and the problem
remains.

Have you tried going through the Office PIA instead?
 
S

Steve Richter

E

Elton Wang

Hi Steve,

If you want to run excel automation on client-side via web
page, it is even worse idea. Internet browser has security
limit of restricting to access client-side local
resources. The ASPNET account permission is only on server-
side. You can't set permission to access client-side
resources; otherwise it's very easy for someone to make
harmful code.

Anyway, it seems you just want to export datagrid to excel
file. There is a easier way to do it. You can use
datagrid's RenderControl methos to build a string to
StringWriter object (via HtmlTextWriter object), set
Response.ContentType as "application/vnd.ms-excel", and
use Response.write to output StringWriter's content.
(I can post the code. Each time I posted code of exporting
datagrid to excel, it showed very strange signs. It's easy
for you to search the code.)


HTH

Elton Wang
 
S

Steve Richter

Elton said:
Hi Steve,

If you want to run excel automation on client-side via web
page, it is even worse idea. Internet browser has security
limit of restricting to access client-side local
resources. The ASPNET account permission is only on server-
side. You can't set permission to access client-side
resources; otherwise it's very easy for someone to make
harmful code.

makes sense. too bad though, it is very functional. And I would still
like to know why it does not work!
Anyway, it seems you just want to export datagrid to excel
file. There is a easier way to do it. You can use
datagrid's RenderControl methos to build a string to
StringWriter object (via HtmlTextWriter object), set
Response.ContentType as "application/vnd.ms-excel", and
use Response.write to output StringWriter's content.
(I can post the code. Each time I posted code of exporting
datagrid to excel, it showed very strange signs. It's easy
for you to search the code.)

I have tested that method and it looks like great functionality. Would
prefer that the excel application start in its own familiar window, but
that is ok.

I guess this method is the prefered, secure way of exporting web page
contents to a client side application. Curious how I can write my own
client side application that functions like excel does in this context.

thanks,

-Steve
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top