Excel still running after "quit" command

S

Sam Hill

Hi all,
I have recently written a complex (for me) program that runs in an
HP-VEE environment, whereas certain Excel macros are called to run as
part of the process. The program is working but I have run into two
difficulties that need to be ironed out, one of which involves Excel
and the other involves VEE.

Problem1:
After the process is complete Excel can still be seen running in the
Task Manager processes table. I will now list several lines of code
from the VEE environment that will hopefully shed some light.

There is a Formula object with the following code:

Set ExcelWkbk=createObject("Excel.Sheet"); // Launch Excel
Set ExcelApp=ExcelWkbk.Application; // Assign the application object
ExcelApp.Visible = FALSE; // Make Excel invisible
ExcelWkbk.Close(); // Close blank wkbk
ExcelApp.Workbooks.Open(xlsFileSpec); // Open file containing macros
ExcelApp.Windows(1).WindowState = xlMaximized;

After myriad processes, there is final Formula object that includes
the following:

ExcelApp.Quit()

I have tried adding the following to the same object:

Set ExcelWkbk = Nothing
Set ExcelApp = Nothing

The problem here is that I get an error message stating VEE does not
recognize "Nothing." I tried adding these same "= Nothing" statements
at the end of the last Excel macro to run. I did not get any errors,
but Excel was still running in Task Manager after the program ran.
Any suggestions?

Problem 2:
I have created the VEE program as a runtime process. I have found
that VEE runtime programs are apparently designed to initiate
automatically upon opening, then close automatically upon completion.
I have gotten around this by starting with an "Until Break" object
which pings a "Confirm" object. Once the user clicks the "Confirm"
object the program runs and then pauses again on Confirm. This worked
fine until I added an "On Cycle" object following Confirm. The
purpose of this is so that the program will run automatically every 30
minutes. This leads to the problem: How to allow a user to STOP the
program, thereby requiring the "Confirm" object to be clicked to
restart it. So far the only way I have found that works is to close
the program and reopen it, once again enabling the "Confirm" object.
There must be some way to do this without having to close the program.
Any suggestions here? I realize this is group for the Excel experts,
but I am hoping there is also some familiarity with VEE. (Maybe
someone could suggest a more appropriate group for VEE-based
questions?)


Any help would be greatly appreciated.

Thank you,

S.
 
J

Jim Cone

S.,

I know nothing of VEE, however plunging ahead, some comments...

1.When you close an Excel workbook that has had changes made
to it, Excel will want to know if the workbook changes should be saved.
It will display a box asking that question and it must be answered or
Excel won't quit. To avoid this use code ...
ExcelWkbk.Close True ' to save, False to not save

2. I would change your first two lines so that the application
is created first ...
Set ExcelApp = CreateObject("Excel.Application")
set ExcelWkbk = ExcelApp.Workbooks.Open(xlsFileSpec)

3.The application should open as not visible.
If the application is invisible, there shouldn't be any need to
maximize the window?

4. Excel automation has a propensity to create orphan references
which prevent Excel from closing. To prevent this, use object
references to all Excel objects, do not use ActiveAnything or
selection ...
Set objSheet = ExcelWkbk.Worksheets(1)
objSheet.Range("A1").Value = "Mush"
etc...

5.All object references should be set to nothing before quitting and
after quitting the Application reference should be set to nothing.
I trust that your VEE program automatically sets object
references to nothing. It has to be done somehow.

Hope some of this helps.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



Hi all,
I have recently written a complex (for me) program that runs in an
HP-VEE environment, whereas certain Excel macros are called to run as
part of the process. The program is working but I have run into two
difficulties that need to be ironed out, one of which involves Excel
and the other involves VEE.

Problem1:
After the process is complete Excel can still be seen running in the
Task Manager processes table. I will now list several lines of code
from the VEE environment that will hopefully shed some light.

There is a Formula object with the following code:

Set ExcelWkbk=createObject("Excel.Sheet"); // Launch Excel
Set ExcelApp=ExcelWkbk.Application; // Assign the application object
ExcelApp.Visible = FALSE; // Make Excel invisible
ExcelWkbk.Close(); // Close blank wkbk
ExcelApp.Workbooks.Open(xlsFileSpec); // Open file containing macros
ExcelApp.Windows(1).WindowState = xlMaximized;

After myriad processes, there is final Formula object that includes
the following:

ExcelApp.Quit()

I have tried adding the following to the same object:

Set ExcelWkbk = Nothing
Set ExcelApp = Nothing

The problem here is that I get an error message stating VEE does not
recognize "Nothing." I tried adding these same "= Nothing" statements
at the end of the last Excel macro to run. I did not get any errors,
but Excel was still running in Task Manager after the program ran.
Any suggestions?

Problem 2:
I have created the VEE program as a runtime process. I have found
that VEE runtime programs are apparently designed to initiate
automatically upon opening, then close automatically upon completion.
I have gotten around this by starting with an "Until Break" object
which pings a "Confirm" object. Once the user clicks the "Confirm"
object the program runs and then pauses again on Confirm. This worked
fine until I added an "On Cycle" object following Confirm. The
purpose of this is so that the program will run automatically every 30
minutes. This leads to the problem: How to allow a user to STOP the
program, thereby requiring the "Confirm" object to be clicked to
restart it. So far the only way I have found that works is to close
the program and reopen it, once again enabling the "Confirm" object.
There must be some way to do this without having to close the program.
Any suggestions here? I realize this is group for the Excel experts,
but I am hoping there is also some familiarity with VEE. (Maybe
someone could suggest a more appropriate group for VEE-based
questions?)
Any help would be greatly appreciated.
Thank you,

S.
 
S

Sam Hill

Thank you Jim,
I will be looking into the program later this week and I appreciate
your feedback. Thanks for reminding me about the maximize command;
this is a leftoever from when Excel remained visible. Also your
method of saving while closing was not known to me.

I am not sure that VEE provides a provision for setting a value to
nothing. The reason I say this is because there are several Excel
example programs that come with the VEE help files, and when any of
these example programs are run, the result is the same: Excel remains
running after closing. There just has to be a way around this. I
will look closely at my program and utilize your advice.

S. Hill
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top