Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing Excel through ASP.NET (VB.NET)

3 views
Skip to first unread message

Amol

unread,
Nov 3, 2003, 11:04:46 PM11/3/03
to
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

S Gopikrishna

unread,
Nov 4, 2003, 12:12:06 AM11/4/03
to
Hi,

Use <identity impersonate="true"/> in web.config and Run
the application under a seperate account with permissions
to Excel.

Thanks,
Gopi

>.
>

Frosty

unread,
Nov 4, 2003, 8:27:58 AM11/4/03
to
From command prompt / start->run... type dcomcnfg

Select Component Services->Computers->My Compter->DCOM Config

Scroll down and select Microsoft Excel Applicaton

Right click on Microsoft Excel Applicaton and select properties.

Select the Security tab

In Launch Permissions group box click Edit button.

Add the appropriate user for your particular situation. In my case, I
selected MyDomainName\Domain Users.

Make sure that Allow check box is checked for your appropriate user.

Click OK

In Access Permissions group box click Edit button.

Add the appropriate user for your particular situation. In my case, I
selected MyDomainName\Domain Users.

Make sure that Allow check box is checked for your appropriate user.

Click OK

Excel interop will now work via asp.net

"Amol" <anon...@discussions.microsoft.com> wrote in message
news:077301c3a288$c8ba7260$a501...@phx.gbl...

Amol

unread,
Nov 4, 2003, 11:50:24 AM11/4/03
to
Thanx a lot Frosty .. its working now.

Amol

>.
>

0 new messages