Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Excel process still shows in TaskManager

Hi,

I have an Excel MultiPage Form which loads on Workbook_Open event. It
has an Exit button which Unloads the Form & runs the following
Procedure to Close the Workbook and Quit Excel.

Private Sub cmd_Exit_Click()

Unload MainForm

Call QuitApplication

End Sub

Public Sub QuitApplication()

With ThisWorkbook
' Dim ans As Integer
' ans = MsgBox("Do you want to SAVE changes?", vbInformation +
vbYesNo, "Save Workbook")
' If ans = vbYes Then
.Close savechanges:=True
' Else
' .Close savechanges:=False
' End If
End With

Application.Visible = True
For Each obj In Excel.Application
Set obj = Nothing
Next obj

Application.Quit

End Sub


Why is Excel not quitting cleanly? I already checked if there are any
loaded Addins, which in my case there is only the default Funcres.xla
& ATPVBAEN.xla seen in VBE Editor.

I have tried to close all objects in code as well as in the form.



Anyone has any answers?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel process still shows in TaskManager

Move the QuitApplication sub to a standard module and call it from the same sub that loaded the form....

MainForm.Show
Call QuitApplication
--
Jim Cone
Portland, Oregon USA

..
..

"noname"
wrote in message
...
Hi,
I have an Excel MultiPage Form which loads on Workbook_Open event. It
has an Exit button which Unloads the Form & runs the following
Procedure to Close the Workbook and Quit Excel.

Private Sub cmd_Exit_Click()
Unload MainForm
Call QuitApplication
End Sub

Public Sub QuitApplication()
With ThisWorkbook
' Dim ans As Integer
' ans = MsgBox("Do you want to SAVE changes?", vbInformation +
vbYesNo, "Save Workbook")
' If ans = vbYes Then
.Close savechanges:=True
' Else
' .Close savechanges:=False
' End If
End With

Application.Visible = True
For Each obj In Excel.Application
Set obj = Nothing
Next obj
Application.Quit
End Sub


Why is Excel not quitting cleanly? I already checked if there are any
loaded Addins, which in my case there is only the default Funcres.xla
& ATPVBAEN.xla seen in VBE Editor.
I have tried to close all objects in code as well as in the form.
Anyone has any answers?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Excel process still shows in TaskManager

On Sep 2, 4:45*pm, "Jim Cone" wrote:
Move the QuitApplication sub to a standard module and call it from the same sub that loaded the form....

MainForm.Show
Call QuitApplication
--
Jim Cone
Portland, Oregon *USA

.
.

"noname"
wrote in ...
Hi,
I have an Excel MultiPage Form which loads on Workbook_Open event. It
has an Exit button which Unloads the Form & runs the following
Procedure to Close the Workbook and Quit Excel.

Private Sub cmd_Exit_Click()
* * Unload MainForm
* * Call QuitApplication
End Sub

Public Sub QuitApplication()
* * With ThisWorkbook
' * * * *Dim ans As Integer
' * * * *ans = MsgBox("Do you want to SAVE changes?", vbInformation +
* * * * vbYesNo, "Save Workbook")
' * * * *If ans = vbYes Then
* * * * * * .Close savechanges:=True
' * * * *Else
' * * * * * *.Close savechanges:=False
' * * * *End If
* * End With

* * Application.Visible = True
* * For Each obj In Excel.Application
* * * * Set obj = Nothing
* * Next obj
* * Application.Quit
End Sub

Why is Excel not quitting cleanly? I already checked if there are any
loaded Addins, which in my case there is only the default Funcres.xla
& ATPVBAEN.xla seen in VBE Editor.
I have tried *to close all objects in code as well as in the form.
Anyone has any answers?


===========================
Hi Jim,

"and call it from the same sub that loaded the form...."

I did not understand this...

The QuitApplication() sub is located in a Standard Module. The Exit
Button is on the MainForm. There is no code in Workbook_Close(). The
Workbook_Open event shows as :

Private Sub Workbook_Open()

Application.Visible = False

Call DefineNames

Load MainForm

MainForm.Show

End Sub


Any ideas?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel process still shows in TaskManager

"and call it from the same sub that loaded the form"

Move the call to QuitApplication
From...
"Sub cmd_Exit_Click()"

To...
"Sub Workbook_Open".
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware

..
..

"noname"
wrote in message
...

On Sep 2, 4:45 pm, "Jim Cone" wrote:
Move the QuitApplication sub to a standard module and call it from the same sub that loaded the form....

MainForm.Show
Call QuitApplication
--
Jim Cone
Portland, Oregon USA


===========================
Hi Jim,

"and call it from the same sub that loaded the form...."

I did not understand this...

The QuitApplication() sub is located in a Standard Module. The Exit
Button is on the MainForm. There is no code in Workbook_Close(). The
Workbook_Open event shows as :

Private Sub Workbook_Open()

Application.Visible = False

Call DefineNames

Load MainForm

MainForm.Show

End Sub

Any ideas?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Excel process still shows in TaskManager

On Sep 2, 6:02*pm, "Jim Cone" wrote:
*"and call it from the same sub that loaded the form"

Move the call to QuitApplication
From...
"Sub cmd_Exit_Click()" *

To...
"Sub Workbook_Open".
--
Jim Cone
Portland, Oregon *USAhttp://www.mediafire.com/PrimitiveSoftware

.
.

"noname"
wrote in ...

On Sep 2, 4:45 pm, "Jim Cone" wrote:

Move the QuitApplication sub to a standard module and call it from the same sub that loaded the form....


MainForm.Show
Call QuitApplication
--
Jim Cone
Portland, Oregon USA


===========================
Hi Jim,

"and call it from the same sub that loaded the form...."

I did not understand this...

The QuitApplication() *sub is located in a Standard Module. The Exit
Button is on the MainForm. There is no code in Workbook_Close(). The
Workbook_Open event shows as :

Private Sub Workbook_Open()

* * Application.Visible = False

* * Call DefineNames

* * Load MainForm

* * MainForm.Show

End Sub

Any ideas?


====================

Hi Jim,

You mean like this:

Private Sub Workbook_Open()

Application.Visible = False

Call DefineNames

Load MainForm

MainForm.Show

Call QuitApplication

End Sub


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Excel process still shows in TaskManager

On Sep 2, 7:40*pm, noname wrote:
On Sep 2, 6:02*pm, "Jim Cone" wrote:









*"and call it from the same sub that loaded the form"


Move the call to QuitApplication
From...
"Sub cmd_Exit_Click()" *


To...
"Sub Workbook_Open".
--
Jim Cone
Portland, Oregon *USAhttp://www.mediafire.com/PrimitiveSoftware


.
.


"noname"
wrote in ...


On Sep 2, 4:45 pm, "Jim Cone" wrote:


Move the QuitApplication sub to a standard module and call it from the same sub that loaded the form....


MainForm.Show
Call QuitApplication
--
Jim Cone
Portland, Oregon USA


===========================
Hi Jim,


"and call it from the same sub that loaded the form...."


I did not understand this...


The QuitApplication() *sub is located in a Standard Module. The Exit
Button is on the MainForm. There is no code in Workbook_Close(). The
Workbook_Open event shows as :


Private Sub Workbook_Open()


* * Application.Visible = False


* * Call DefineNames


* * Load MainForm


* * MainForm.Show


End Sub


Any ideas?


====================

Hi Jim,

You mean like this:

Private Sub Workbook_Open()

* * Application.Visible = False

* * Call DefineNames

* * Load MainForm

* * MainForm.Show

* * Call QuitApplication

End Sub


==================

Well, i tried that, and its still the same....


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel process still shows in TaskManager

This part of your code doesn't work and generates an error. Get rid of it....
'---
For Each obj In Excel.Application
Set obj = Nothing
Next obj
'---
You don't say from where or how you are starting Excel.
I assume from a VB application. And you must have set a reference
to Excel in your project or are using CreateObject to return a reference.

So shown below is something I put together a few years back to provide
some general guidelines for automating Excel.
Note the last sentence...
'---
1. Set a reference to the primary Excel objects used in your program.
Dim xlApp As Excel.Application
Dim WB As Excel.Workbook
Dim WS As Excel.Worksheet

Set xlApp = New Excel.Application
Set WB = xlApp.Workbooks.Add
Set WS = WB.Sheets(1)

Use the appropriate reference Every Time you make reference to a spreadsheet.
Do not use Range(xx) - use WS.Range(xx)
Cells should be WS.Cells(10, 20) or _
WS.Range(WS.Cells(10, 20), WS.Cells(20, 40))

2. Avoid the use of ActiveSheet, ActiveWorkbook, Selection etc.
Use your object references.

3. Avoid the use of the "With" construct.

4. Set all objects to Nothing in the proper order - child then parent.
Set WS = Nothing
WB.Close SaveChanges:=True 'your choice
Set WB = Nothing
xlApp.Quit
Set xlApp = Nothing

Violating any of these guidelines can leave "orphans" that still refer
to Excel and prevent the application from closing.
--
Jim Cone
Portland, Oregon USA

..
..

"noname"
wrote in message
...
On Sep 2, 7:40 pm, noname wrote:
On Sep 2, 6:02 pm, "Jim Cone" wrote:


Well, i tried that, and its still the same....


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Excel process still shows in TaskManager

On Sep 2, 8:53*pm, "Jim Cone" wrote:
This part of your code doesn't work and generates an error. *Get rid of it....
'---
* * For Each obj In Excel.Application
* * * * Set obj = Nothing
* * Next obj
'---
You don't say from where or how you are starting Excel.
I assume from a VB application. *And you must have set a reference
to Excel in your project or are using CreateObject to return a reference.

So shown below is something I put together a few years back to provide
some general guidelines for automating Excel.
Note the last sentence...
'---
1. Set a reference to the primary Excel objects used in your program.
* *Dim xlApp As Excel.Application
* *Dim WB As Excel.Workbook
* *Dim WS As Excel.Worksheet

* *Set xlApp = New Excel.Application
* *Set WB = xlApp.Workbooks.Add
* *Set WS = WB.Sheets(1)

* *Use the appropriate reference Every Time you make reference to a spreadsheet.
* *Do not use Range(xx) - use WS.Range(xx)
* *Cells should be WS.Cells(10, 20) or _
* * * * * * * * * *WS.Range(WS.Cells(10, 20), WS.Cells(20, 40))

2. Avoid the use of ActiveSheet, ActiveWorkbook, Selection etc.
* *Use your object references.

3. Avoid the use of the "With" construct.

4. Set all objects to Nothing in the proper order - child then parent.
* *Set WS = Nothing
* *WB.Close SaveChanges:=True 'your choice
* *Set WB = Nothing
* *xlApp.Quit
* *Set xlApp = Nothing

Violating any of these guidelines can leave "orphans" that still refer
to Excel and prevent the application from closing.
--
Jim Cone
Portland, Oregon *USA

.
.

"noname"
wrote in ...
On Sep 2, 7:40 pm, noname wrote:

On Sep 2, 6:02 pm, "Jim Cone" wrote:


Well, i tried that, and its still the same....


=================

Thanks Jim,

Though i was not Automating Excel application. Anyways, i found the
reason why it was happening. I was first closing the Workbook (where
the running code lay) and then trying to quit Excel Application. so
the code stops running once Workbook is closed & hence Excel
Application still stays in memory.

So solution:
----------------

Instead of closing Workbook, i just saved the workbook, using
Workbook.Save. Then ran the usual Application.Quit statement and that
did the work.

Thank n best regards. :)
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Result shows correct answer but cell shows 0 Lise Excel Discussion (Misc queries) 1 March 2nd 10 01:23 PM
macro for closing all Excel processes visible in TaskManager [email protected] Excel Programming 1 June 12th 08 10:57 AM
Schedule taskmanager via code? Steph[_3_] Excel Programming 1 March 25th 05 06:10 PM
How to count process running time ( process not finished) miao jie Excel Programming 0 January 13th 05 09:23 AM
How to count process running time ( process not finished) miao jie Excel Programming 2 January 12th 05 06:01 AM


All times are GMT +1. The time now is 06:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"