Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop the the excel process in task Manager 1

Status
Not open for further replies.

itmasterw

Programmer
Apr 13, 2003
147
US
Hi,
I have code that opens Excel and inputs data, but some times it gets hung up because Excel is left runing in the backround. ANd my code has xl1.ActiveWorkbook.Save
xl1.Quit which seems to do nothing.
Is there any way to kill the the excel process, before I run my code, that may be left runing in the task Manager.
Thank You


ITM
 
it gets hung up because Excel is left runing in the backround
Can't you avoid that ?
Seems you have some implicit instantiation of the Excel object in your code like, say, Selection instead of xl1.Selection or ActiveCell instead of xl1.ActiveCell

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
No if I use this samwe code like I ma doing now it runs just fine. But there is something Access, maybe sharing the same dills as Excel, that this happens here. I heard that htere is an API call that you can use to turn off process. Or something like it, but I am not sure wwhat.

ITM
 
Much depends on how you are intantiating Excel, however if you have variables eg sht as Sheet, wkb as Workbook and set them to Nothing after you have finished with them. Then assuming you have xl as Excel then after xl.Quit, setting xl to Nothing should do the trick.

 
No that surprises me too, but as you can see in me question I do have that, and it still does not work. But if I move it ot a vb program it works fine. I have seen this before and I heard that there is a an API function that handels this.
Thanks

ITM
 
An API might cure the symptoms, but, as indicated by PHV, the most common culprit is hvaing something in the code that makes an implicit instantiation of Excel - which is the problem.

If you are 100% sure that is not the problem - and I mean 100% - a reinstall of Excel might do, and/or check if you have other programs, perhaps especially Excel Add-Ins that might interfere. In such case, remove them, and check what happens without them installed.

But this is all rather theoretical. There are several members here who are able to see possible culprits/problems in automation code, but we (at least I) don't bother guessing without information... -> the code

And please, if something works on one version, that's absolutely no guarantee it will work everywhere. Just take something as simple as referencing subforms/subreports. Access 2002 and prior version are often very forgiving when using incorrect syntax, while 2003 often demands correct syntax (-> including the Form keyword in the reference).

Roy-Vidar
 
I agree with RoyVidar,

I had similar trouble two weeks ago (thread thread705-1032299) and eventually after deinstalling and reisntlaling office 2003 the problem was solved.

Maarten
 
I appreacite everyones help, but unfortunantly I can not install and Un install apps at work; and i can nt request this for everyone at the job. But I know I once saw this API call and it solved the problem, I quess I will keep Looking.
Thank You

ITM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top