|
-
Feb 16th, 2006, 11:49 AM
#1
Thread Starter
Frenzied Member
[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:
'Added Code
'*********************************************************************************
<DllImport("user32")> _
Private Shared Function SendMessage(ByVal hwnd As Integer, ByVal msg As Integer, _
ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function
Private Const WM_DESTORY As Integer = &H2
'*********************************************************************************
Private Sub SaveToExcelFormat(ByVal filename As String, ByVal ds As DataSet)
Dim XlsApp As New Excel.Application
XlsApp.Visible = False
XlsApp.DisplayAlerts = False
Try
Dim XlsWorkBook As Excel.Workbook = XlsApp.Workbooks.Add
Try
Dim XlsWorkSheet As Excel.Worksheet = CType(XlsWorkBook.Worksheets(1), Excel.Worksheet)
Catch exSheet As Exception
MsgBox(exSheet.ToString)
End Try
XlsWorkBook.SaveAs(filename.Substring(0, filename.LastIndexOf(".")))
XlsWorkBook.Close()
Catch exBook As Exception
MsgBox(exBook.ToString)
End Try
If Not XlsApp Is Nothing Then
XlsApp.Quit()
'Added Code
'************************************
SendMessage(XlsApp.Hwnd, WM_DESTORY, 0, 0)
'************************************
XlsApp = Nothing
End If
GC.Collect()
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
-
Sep 24th, 2006, 02:19 PM
#2
Lively Member
Re: [RESOLVED] instance of excel still in taskmanager
Resolved??
Then what was the solution.
I would like to know that too!!
Richard(newbie)
-
Sep 24th, 2006, 02:40 PM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|