How do I stop an EXCEL Process

J

Jim

I have a application written in VB6 that accesses a database and outputs to
EXCEL.
The output ends with "MYexcel.quit" and the relevant prompt displays. If I
exit Excel atthat stage the EXCEL process is left running as seen in
Taskmanager.
Run the program a couple of times and soon the machine grinds to a halt.

So the question is - How do I stop/exit from excel via VB
 
R

RB Smissaert

More than likely this is caused by references that are not set to nothing.
So before doing MYexcel.Quit make sure
that all these references are released.
If I remember welll there also can be a problem with the With End With
construction. If the above fails try to get
rid of this.

RBS
 
S

Stephen Bullen

Hi Jim,
I have a application written in VB6 that accesses a database and outputs to
EXCEL.
The output ends with "MYexcel.quit" and the relevant prompt displays. If I
exit Excel atthat stage the EXCEL process is left running as seen in
Taskmanager.
Run the program a couple of times and soon the machine grinds to a halt.

So the question is - How do I stop/exit from excel via VB

My guess is that somewhere in your code, you're not explicitly refering to
your MyExcel object, but using what's normally a 'global' object in Excel
without qualifying it, such as:

Set oRange = oSheet.Range(Cells(1,2), Cells(10,20))

In that case, the Cells() bits aren't qualified. That causes VB to create its
own internal object to reference the Excel application, which often leaves an
Excel process running.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev
 

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