Hi,
Use <identity impersonate="true"/> in web.config and Run
the application under a seperate account with permissions
to Excel.
Thanks,
Gopi
>-----Original Message-----
>Hi All,
>
>I am developing an application which requires opening an
>Excel Workbook through ASP.NET code, raise a few events
>to execute VBA code and then get results from Excel and
>display them on web-page. I am getting 'Access is
Denied'
>error. I tried to give full permissions to ASPNET user
to
>Excel.EXE, the directory in which .xls file is stored
and
>even windows root, but the error still persists. It is
>not able to execute the line 'MyXL = New
>Excel.Application'.
>
>I have spent a lot of time working on this problem. Any
>help is appreciated.
>
>I tried the following code:
>Imports Microsoft.Office.Interop
>
>Public Sub writeExcel(ByRef s As String, ByRef locn As
>String)
> Dim MyXL As Excel.Application
> Dim MyWB As Excel.Workbook
> MyXL = New Excel.Application
> MyWB = MyXL.Workbooks.Open("C:/SomeBook.xls")
> MyWB.Worksheets("Sheet1").Range(locn).Value = s
> MyWB.Save()
> MyWB.Close()
> MyWB = Nothing
> MyXL.Quit()
> MyXL = Nothing
>End Sub
>
>ERROR:
>Access is denied.
>Description: An unhandled exception occurred during the
>execution of the current web request. Please review the
>stack trace for more information about the error and
>where it originated in the code.
>
>Exception Details: System.UnauthorizedAccessException:
>Access is denied.
>
>ASP.NET is not authorized to access the requested
>resource. Consider granting access rights to the
resource
>to the ASP.NET request identity. ASP.NET has a base
>process identity (typically {MACHINE}\ASPNET on IIS 5 or
>Network Service on IIS 6) that is used if the
application
>is not impersonating. If the application is
impersonating
>via <identity impersonate="true"/>, the identity will be
>the anonymous user (typically IUSR_MACHINENAME) or the
>authenticated request user.
>
>To grant ASP.NET write access to a file, right-click the
>file in Explorer, choose "Properties" and select the
>Security tab. Click "Add" to add the appropriate user or
>group. Highlight the ASP.NET account, and check the
boxes
>for the desired access.
>
>Thanks.
>
>Regards,
>Amol Goel
>.
>