COM Object method .Quit() not killing process

Put simple Tips and Tricks that are not entire Tutorials in this forum
Stavencross
Posts: 90
Joined: 24 May 2016, 16:42

COM Object method .Quit() not killing process

25 Sep 2018, 13:31

I spent about 6 hours this week struggling with powerpoint not quitting when I was calling the .Quit() method. I stumbled across :
https://stackoverflow.com/questions/319 ... ar-process
which lead me to
https://support.microsoft.com/en-us/hel ... l-studio-n

Although this is for C#/.net, the idea is the same. If you're passing your COM Obj around between functions, or using global vars, microsoft essentially keeps a counter of the times you called it. Hence, when you call ".Quit()" it kills the COM Obj, but NOT the program itself.

To resolve, Here's what I did:

Code: Select all


	global ppt := "" ;First, set your ComObj to null, this will reset microsoft's stupid counter.
	ppt := ComObjActive("PowerPoint.Application") ;reconnect to your COM obj
	ppt.Quit() ;It dies.
	
Just wanted to save someone the frustration I went through
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: COM Object method .Quit() not killing process

16 Mar 2019, 20:55

I do not have experience with ppt
but
in MS Excel, I made it a rule to kill it out;

Code: Select all

oExcel.Quit					; 	kill Object
oExcel =					; 	kill Process
On the contrary, only the first one is good enough for the MS Word

Return to “Tips and Tricks (v1)”

Who is online

Users browsing this forum: No registered users and 20 guests