Results 1 to 3 of 3

Thread: [RESOLVED] instance of excel still in taskmanager

  1. #1

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Resolved [RESOLVED] instance of excel still in taskmanager

    *EDIT*
    nevermind i found a way to kill the instance that i don't want and to ensure that any other would be killed after the method finishes. I added the following see code...


    ok hopefully someone can explain to me why the following is happening

    first here's the code that i have, that i just started just want to make sure everything work the way it should for starters...

    VB Code:
    1. 'Added Code
    2.     '*********************************************************************************
    3.     <DllImport("user32")> _
    4.     Private Shared Function SendMessage(ByVal hwnd As Integer, ByVal msg As Integer, _
    5.         ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
    6.  
    7.     End Function
    8.     Private Const WM_DESTORY As Integer = &H2
    9.     '*********************************************************************************
    10.     Private Sub SaveToExcelFormat(ByVal filename As String, ByVal ds As DataSet)
    11.         Dim XlsApp As New Excel.Application
    12.         XlsApp.Visible = False
    13.  
    14.         XlsApp.DisplayAlerts = False
    15.         Try
    16.             Dim XlsWorkBook As Excel.Workbook = XlsApp.Workbooks.Add
    17.  
    18.             Try
    19.                 Dim XlsWorkSheet As Excel.Worksheet = CType(XlsWorkBook.Worksheets(1), Excel.Worksheet)
    20.  
    21.             Catch exSheet As Exception
    22.                 MsgBox(exSheet.ToString)
    23.             End Try
    24.             XlsWorkBook.SaveAs(filename.Substring(0, filename.LastIndexOf(".")))
    25.             XlsWorkBook.Close()
    26.         Catch exBook As Exception
    27.             MsgBox(exBook.ToString)
    28.         End Try
    29.  
    30.         If Not XlsApp Is Nothing Then
    31.             XlsApp.Quit()
    32.             'Added Code
    33.             '************************************
    34.             SendMessage(XlsApp.Hwnd, WM_DESTORY, 0, 0)
    35.             '************************************
    36.             XlsApp = Nothing
    37.         End If
    38.         GC.Collect()
    39.     End Sub

    ok here's the issue, if you would call it that, that i'm running into. my app is a mdi i have two child windows open in it... i do a save as set it to excel and it running the method. now i have task manager open because i wanted to make sure that excel was starting up and shutting down. the first time i do the save as excel starts but does not shut down, if i do it again it starts and shuts down. i see the first instance in TM'er and it's still sitting there i see the other pop up in there and then go away. so my question is why is it that the first one stays and any other instance will actually quit???
    Last edited by vbdotnetboy; Feb 16th, 2006 at 01:41 PM. Reason: Resolved

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  2. #2
    Lively Member
    Join Date
    Sep 2006
    Posts
    95

    Re: [RESOLVED] instance of excel still in taskmanager

    Resolved??

    Then what was the solution.
    I would like to know that too!!

    Richard(newbie)

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] instance of excel still in taskmanager

    Its not quitting because of the two resources left instanciated - XlsWorkSheet XlsWorkbook. They need to be destroyed so the resources can be free'd before Excel can close.

    @Richnl, see his remarks about the added api code "'Added Code"
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width