interop >> RE : Accessing Excel through ASP.NET (VB.NET)

by S Gopikrishna » Tue, 04 Nov 2003 13:12:06 GMT

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
>.
>


Similar Threads

1. Accessing Excel through ASP.NET (VB.NET)

2. How to read Excel file in asp/Asp.net/vb/vb.net

I am writing  a program in that i need to read the excel file.
Any can help me in this  context

3. Opening word, excel, pp document under asp.net with VB.net code behind - Asp.Net

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

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