|
-
Sep 12th, 2005, 01:07 AM
#1
Thread Starter
Addicted Member
Last edited by v_gyku; Sep 19th, 2005 at 04:04 AM.
-
Sep 12th, 2005, 01:10 AM
#2
Re: kill excel instance
You need to explicitly 'Close' the instance of Excel. All you have done (in your example) is destroyed the Object you created 
So try: objExcel.Close
then destroy objExcel
-
Sep 12th, 2005, 01:21 AM
#3
Re: kill excel instance
You need to set the sheet to nothing, close the workbook, set the workbook to nothing, quit the application, and then set the application to nothing.
In that order:
VB Code:
Set ExlSheet = Nothing
ExlWorkBook.Close SaveChanges:=False
Set ExlWorkBook = Nothing
ExlAppTemp.Quit
Set ExlAppTemp = Nothing
Exit Sub
-
Sep 12th, 2005, 01:32 AM
#4
Re: kill excel instance
You are only setting the Excel Object to nothing if you close it there.
You should set it to nothing regardless. Put the duplicated code after the if statemnt. It won't hurt to set it to nothing twice.
Follow the steps above with everything.
Here is a module I use to close my apps.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim frm As Form
Dim obj As Object
For Each frm In Forms
If frm.Name <> Me.Name Then ' Unload this form LAST
For Each obj In frm
On Error Resume Next
Unload obj
Set obj = Nothing
Next
Unload frm
Set frm = Nothing
End If
Next
On Error Resume Next
For Each obj In frm
Unload obj
Set obj = Nothing
Next
Set frm = Nothing
Unload Me
End Sub
-
Sep 12th, 2005, 10:00 AM
#5
Re: kill excel instance
There may be a problem with your IsAppOpen function. Do you really need to use this? Can you post the code for it?
-
Sep 12th, 2005, 10:14 AM
#6
Re: kill excel instance
 Originally Posted by dglienna
You are only setting the Excel Object to nothing if you close it there.
You should set it to nothing regardless. Put the duplicated code after the if statemnt. It won't hurt to set it to nothing twice.
Follow the steps above with everything.
Here is a module I use to close my apps.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim frm As Form
Dim obj As Object
For Each frm In Forms
If frm.Name <> Me.Name Then ' Unload this form LAST
For Each obj In frm
On Error Resume Next
Unload obj
Set obj = Nothing
Next
Unload frm
Set frm = Nothing
End If
Next
On Error Resume Next
For Each obj In frm
Unload obj
Set obj = Nothing
Next
Set frm = Nothing
Unload Me
End Sub
This will not work with Excel objects as it is more used for VB variable objects. 
Without seeing all your Excel code we can not determine what your leaving open. You MUST close and destroy all Excel objects and quit and destroy the application(s) object(s) in order to release all references to Excel and allow it to close.
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 
-
Sep 12th, 2005, 10:45 AM
#7
Hyperactive Member
Re: kill excel instance
I have never had a problem qoing a myExcel.Quit function then setting all my excel objects to nothing. The program closes just fine and I think I am getting all of my resources back. Am I wrong? I know that Excel closes when I do this without issue.
-
Sep 12th, 2005, 10:47 AM
#8
Re: kill excel instance
It may close fine and not show in the taskmanager but I do believe that the references would still be resident and not relase all your resources. 
Edit: Moved to Office Development Forum.
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 
-
Sep 12th, 2005, 10:49 AM
#9
Re: kill excel instance
To close without saving....
myExcel.DisplayAlerts = False
myExcel.Quit
then set objects = Nothing
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Sep 12th, 2005, 10:55 AM
#10
Re: kill excel instance
Instead of .DisplayAlerts you could do the same thing with setting the .Saved property of the workbook to True in order to bypass the prompt.
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 
-
Sep 15th, 2005, 06:48 AM
#11
Thread Starter
Addicted Member
Re: kill excel instance
Hey guys ! I am not getting the solution.
I need ur help guys!
I am trying this :
I have also tried many other things:
Once i write the following code i think excel should go from the taskbar..
is there any thing which i might have done because of which it might not be going?
Code:
ObjExcel.Quit
Set ObjExcel = Nothing
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
|