closing excel

Discussion in 'ASP .Net' started by Mark, Apr 13, 2004.

  1. Mark

    Mark Guest

    Hi all,

    as many had, i have some problems terminating the excel-process.
    I implemented the solutions i found in this forums. Tried most
    combinations of them ;-).
    It still doesn't work.

    I'll post my code-snippets below. I hope u can shine some light on the
    solution.

    Thx,

    Mark

    <code>
    Dim excelApp As Excel.Application = New Excel.Application
    Dim excelWorkbook As Excel.Workbook
    Dim excelSheetInput As Excel.Worksheet
    Dim excelSheetOutput As Excel.Worksheet

    <doin sumthing>

    Finally
    excelSheetInput = Nothing
    ReleaseCOMObject(excelSheetInput)
    excelSheetOutput = Nothing
    ReleaseCOMObject(excelSheetOutput)
    'excelWorkbook.Close()
    excelWorkbook = Nothing
    ReleaseCOMObject(excelWorkbook)
    excelApp.Quit()
    excelApp = Nothing
    ReleaseCOMObject(excelApp)
    System.GC.Collect()
    End Try
    </code>
    <code>
    Try
    System.Runtime.InteropServices.Marshal.ReleaseComObject(pobj)
    Catch
    Finally
    pobj = Nothing
    End Try
    </code>
     
    Mark, Apr 13, 2004
    #1
    1. Advertising

  2. This article shows how to shut down Excel and it worked for me.
    http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp

    But really you shouldn't be using Excel from an ASP.NET application. It
    just wasn't designed for scenarios like this so I'm not surprised its giving
    you problems. The article also explains other ways to use Excel documents,
    and it lists a couple of fine 3rd party products that might also help.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net




    "Mark" <> wrote in message
    news:...
    > Hi all,
    >
    > as many had, i have some problems terminating the excel-process.
    > I implemented the solutions i found in this forums. Tried most
    > combinations of them ;-).
    > It still doesn't work.
    >
    > I'll post my code-snippets below. I hope u can shine some light on the
    > solution.
    >
    > Thx,
    >
    > Mark
    >
    > <code>
    > Dim excelApp As Excel.Application = New Excel.Application
    > Dim excelWorkbook As Excel.Workbook
    > Dim excelSheetInput As Excel.Worksheet
    > Dim excelSheetOutput As Excel.Worksheet
    >
    > <doin sumthing>
    >
    > Finally
    > excelSheetInput = Nothing
    > ReleaseCOMObject(excelSheetInput)
    > excelSheetOutput = Nothing
    > ReleaseCOMObject(excelSheetOutput)
    > 'excelWorkbook.Close()
    > excelWorkbook = Nothing
    > ReleaseCOMObject(excelWorkbook)
    > excelApp.Quit()
    > excelApp = Nothing
    > ReleaseCOMObject(excelApp)
    > System.GC.Collect()
    > End Try
    > </code>
    > <code>
    > Try
    > System.Runtime.InteropServices.Marshal.ReleaseComObject(pobj)
    > Catch
    > Finally
    > pobj = Nothing
    > End Try
    > </code>
     
    Steve C. Orr [MVP, MCSD], Apr 13, 2004
    #2
    1. Advertising

  3. Mark

    Mark Guest

    Ty for your response.
    I solved, thx to other sources, by specificly use variables for all
    objects used in the process (sheets-collection etc.) and placing the
    close- quit and terminate-statements in the rite order.

    I will study the article u r referring too.
    Maybe i will find some good arguments which i can use to convince my
    client not to use Excel. They kinda insist at the mo in using Excel
    (hey it works fine with j2ee too).

    Grtz,

    Mark

    "Steve C. Orr [MVP, MCSD]" <> wrote in message news:<#>...
    > This article shows how to shut down Excel and it worked for me.
    > http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp
    >
    > But really you shouldn't be using Excel from an ASP.NET application. It
    > just wasn't designed for scenarios like this so I'm not surprised its giving
    > you problems. The article also explains other ways to use Excel documents,
    > and it lists a couple of fine 3rd party products that might also help.
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    >
    >
    >
    >
    > "Mark" <> wrote in message
    > news:...
    > > Hi all,
    > >
    > > as many had, i have some problems terminating the excel-process.
    > > I implemented the solutions i found in this forums. Tried most
    > > combinations of them ;-).
    > > It still doesn't work.
    > >
    > > I'll post my code-snippets below. I hope u can shine some light on the
    > > solution.
    > >
    > > Thx,
    > >
    > > Mark
    > >
    > > <code>
    > > Dim excelApp As Excel.Application = New Excel.Application
    > > Dim excelWorkbook As Excel.Workbook
    > > Dim excelSheetInput As Excel.Worksheet
    > > Dim excelSheetOutput As Excel.Worksheet
    > >
    > > <doin sumthing>
    > >
    > > Finally
    > > excelSheetInput = Nothing
    > > ReleaseCOMObject(excelSheetInput)
    > > excelSheetOutput = Nothing
    > > ReleaseCOMObject(excelSheetOutput)
    > > 'excelWorkbook.Close()
    > > excelWorkbook = Nothing
    > > ReleaseCOMObject(excelWorkbook)
    > > excelApp.Quit()
    > > excelApp = Nothing
    > > ReleaseCOMObject(excelApp)
    > > System.GC.Collect()
    > > End Try
    > > </code>
    > > <code>
    > > Try
    > > System.Runtime.InteropServices.Marshal.ReleaseComObject(pobj)
    > > Catch
    > > Finally
    > > pobj = Nothing
    > > End Try
    > > </code>
     
    Mark, Apr 14, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Winshent
    Replies:
    0
    Views:
    1,987
    Winshent
    Nov 3, 2004
  2. Closing Excel on server

    , Sep 5, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    524
  3. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    678
    Thomas Hansen
    Feb 15, 2007
  4. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,596
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  5. thomas
    Replies:
    0
    Views:
    251
    thomas
    Oct 23, 2003
Loading...

Share This Page