locked
Error Opening Excel Application in IIS7 RRS feed

  • Question

  • User-144431078 posted

    First, sorry about my english. I've a problem (it seems to be something very easy) with Opening Excel Application by ASP in IIS7. This code works fine in IIS6.


    Set objFSO = CreateObject("Scripting.FileSystemObject") 
    If objFSO.FileExists(Server.MapPath("/Today/File.xls")) then
      Set xl1 = CreateObject("Excel.Application")
      Set wb1 = xl1.Workbooks.Open(Server.MapPath("/Today/File.xls"))
      wb1.Close()
      xl1.Application.Quit()
      response.write "&load=ok"
    end if
     

    I know that the error is in the line [Set wb1 = xl1.Workbooks.Open(Server.MapPath("/Today/File.xls"))]The error that appears is the next:

    HTTP Error 500: Server internal Error. Description: There is a problem with the resource that it looks for and it is not possible to be shown.

    Saturday, April 21, 2007 1:11 PM

All replies

  • User1356161706 posted

    Did you turn on the following setting?

    http://blogs.iis.net/thomad/archive/2007/02/06/security-is-painful.aspx

    Hope this helps.

    Sunday, April 22, 2007 1:08 AM
  • User-144431078 posted

    Yes. And I have "Excel" installed and all the Authentications and writing permissions correct. But I don´t know why is imposible to open Excel or Word applications with asp in IIS7.

    Set xl=CreateObject("Excel.Application") is not giving Error, but Set wb=xl.Workbooks.Open("File.xls") yes.

    This code works O.K. with IIS6.

    The error descriptions talks about Resources, but where are those resources? 

    Sunday, April 22, 2007 9:09 AM
  • User1356161706 posted

    I can't get this to work either. I get the following error:

    Microsoft Office Excel error '800a03ec'

    Microsoft Office Excel cannot access the file 'D:\inetpub\wwwroot\test.xls'. There are several possible reasons: • The file name or path does not exist. • The file is being used by another program. • The workbook you are trying to save has the same name as a currently open workbook.

    /xl.asp, line 7

    What is the exact error you are getting and which Office version are you using?

     

     

    Sunday, April 22, 2007 2:03 PM
  • User-144431078 posted

    • The file name or path does not exist. It´s Correct.

    • The file is being used by another program. Excel is closed.

    • The workbook you are trying to save has the same name as a currently open workbook. Excel is closed.

    Exact error (Traslate from other Language): HTTP Error 500: Server internal Error. Description: There is a problem with the resource that it looks for and it is not possible to be shown.

    Office version: Office XP Professional, but with Office 2003 I got the same Error.

    SO: Windows Vista Home Premium

    This code works fine in IIS6. And is peculiar that IIS7 is not giving any Error with Set Xl=CreateObject("Excel.Application") and only when Opening.

    I don´t know if it would be something from "ApplicationHost.config" or "Web.config" files.

    Sunday, April 22, 2007 2:48 PM
  • User-144431078 posted

    Does anyone know why IIS7 don´t Find the needed Resource to execute the next code? What Resource is it, and where could I Find? It´s something about Excel Applications.

    set wb = xl.Workbooks.Open(Server.MapPath("/Today/File.xls"))

    This code works well in IIS6. And is peculiar that IIS7 is not giving any Error with Set Xl=CreateObject("Excel.Application") and only when Opening.

    Thanks to everybody.

    Monday, April 23, 2007 6:35 PM
  • User-144431078 posted

    Solved!!!!!!!!

    http://forums.iis.net/1695221/ShowThread.aspx

    Friday, May 4, 2007 11:33 AM
  • User-823196590 posted
    Are you aware of:
    http://support.microsoft.com/?kbid=257757
    Friday, May 4, 2007 4:54 PM
  • User759428418 posted

     

    Hello. It seems I have the same problem. Here is mi case:

    I have a web app that open an excel template, makes some calculations, and save it. After that, it gives the user the option to open or save it. The code is this: 

         Dim f As New Functions
           Dim ds As DataSet = f.EmpleadosEnActivo
           Dim dt As DataTable = ds.Tables(0)
           Dim oExcel As New Excel.Application
           Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook
           Dim oSheets As Excel.Sheets, oSheet As Excel.Worksheet
           Dim oCells As Excel.Range
           Dim sFile As String, sTemplate As String
           sFile = Server.MapPath(Request.ApplicationPath) & "\Excels\MyTemplate.xlsx"
           sTemplate = Server.MapPath(Request.ApplicationPath) & "\Excels\MyTemplate1.xltx"
           oExcel.Visible = False
           oExcel.DisplayAlerts = False
           oBooks = oExcel.Workbooks
           oBooks.Open(Server.MapPath(Request.ApplicationPath) & "\Excels\MyTemplate1.xltx")
           oBook = oBooks.Item(1)
           oSheets = oBook.Worksheets
           oSheet = CType(oSheets.Item(1), Excel.Worksheet)
           oSheet.Name = "CALCULO EMPLEADOS"
           oCells = oSheet.Cells
           f.DumpData(dt, oCells)
           oSheet.Columns.AutoFit()
           oSheet.SaveAs(sFile)
           oExcel.Quit()
           ReleaseComObject(oCells)
           ReleaseComObject(oSheet)
           ReleaseComObject(oSheets)
           ReleaseComObject(oBook)
           ReleaseComObject(oBooks)
           ReleaseComObject(oExcel)
           oExcel = Nothing
           oBooks = Nothing
           oBook = Nothing
           oSheets = Nothing
           oSheet = Nothing
           oCells = Nothing
           System.GC.Collect()
           Response.Clear()
           Response.ContentType = "application/ms-excel"
           Response.AddHeader("Content-disposition", "attachment; filename=" & "RRHH.xlsx")
           Response.WriteFile(".\Excels\MyTemplate.xlsx")
           Response.Flush()
           Response.Close()

     

    The problem is that this works perfectly on mu XP machine under IIS 6. But when I put it in my Vista Ultimate machine with II 7, it doesnt work.... or quite. It onlly works if I execute the app from the Visual Studio IDE. Then it works perfect. But if I use the url http://127.0.0.1..... I get the messae that the file cant be accessed ( just when I am about to open it).  It says it could be due the file doesnt exist (obvisouly not the case), file already in use (not the case) an another on I cant remember, but I can ssure this is not the problem. I have been reading in some forums, doing things with the DCOM configuration for Excel, giving access to the file where the excel file us to some users, admin, network service account, etc. but no use

     

    I am desperate, does any one knows how to solve this?? I am sure this have to do with Vista adn IIS 7, it is obvious since this works perfectly for XP and IIS 6. I am alittle fed up of Vista.................

    Wednesday, May 21, 2008 6:42 PM