Excel object in ASP

K

KLomax

I am trying to use an excel spreedsheet on an asp.net page.
The follow code works (with output mod.) in a .net console
application. When I try to run this code in asp.net,
the "dim new excel app" statement fails
with "System.UnauthorizedAccessException: Access is
denied."
Are there some security settings I need to tweek to
instantiate an Excel object in VB.NET ?
Any ideas would be appreciated.
Regards,
KLomax

Try
Dim objExcel As New Excel.Application()
objExcel.Workbooks.Open("C:\TEMP\TestExcel.xls")
Label1.Text = _
objExcel.ActiveSheet.Cells(1,1).Value.ToString
objExcel.Workbooks.Close()
Catch exp As Exception
Label1.Text = exp.ToString
End Try
 
M

MSFT

By Default, an ASP.NET application will use the account "aspnet". This
account on your computer may not have enough permission to create the Excel
object. You can try to add this account to local administrators group, or
you can open up macine.config and look at the processModel' username
attribute, you will find which NT account your ASP.NET worker process is
running. Usually it's MACHINE or SYSTEM (where the latter one has more
rights to certain COM objects). See if you can play it with SYSTEM account.

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top