FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Cannot close Excel with WIN32OLE
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 03:40 PM

Is there anybody who knows,
what i can do to close Excel ?
With the old TAutoOle : oExcel:End() it was ok.
Antonio told me : oExcel := NIL.
It is not working, because in the Filemanager
Excel is still visible and not closed.

Regards U.König :lol:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 2
Joined: Sat Sep 08, 2007 01:47 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 04:25 PM

With Fivewin and xharbour, just comment your line oxls:end()
You dont need it anymore .
Good luck

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 05:05 PM

I think what you want is

oExcel:quit()
oExcel := nil

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 06:23 PM
Gale FORd wrote:I think what you want is

oExcel:quit()
oExcel := nil


The last is not needed.

EMG
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 07:30 PM

I thought the same as you, but after helping someone with an Excel problem we found that Excel will still be running even though you cannot see it.

Running the task manager after doing the oExcel:quit() shows that Excel would still be resident until the variable was set to nil.

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
End Excel-Worksheet
Posted: Thu Jan 03, 2008 10:00 PM

oExcel:Quit()
oExcel := NIL

works fine.
but it creates the worksheet in the background.

I tried to do nothing on the end.
It works also, but with the difference : Excel shows the sheet
and stays open.
I have to close excel with the button ( because I want to check the sheet )
A Test with the Taskmanager shows, that Excel is closed.

Thank you
U. König :lol:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 11:16 PM

What if you try this way

oExcel:WorkBooks:Close()
oExcel:Quit()

Regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 11:30 PM
Gale FORd wrote:I thought the same as you, but after helping someone with an Excel problem we found that Excel will still be running even though you cannot see it.

Running the task manager after doing the oExcel:quit() shows that Excel would still be resident until the variable was set to nil.


This is definitely not true. Please, show a sample to demonstrate the problem.

EMG
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Cannot close Excel with WIN32OLE
Posted: Thu Jan 03, 2008 11:53 PM

I did not believe it either. I will put something together tomorrow.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Cannot close Excel with WIN32OLE
Posted: Fri Jan 04, 2008 12:31 AM

Ok, thank you. I'm pretty curious...

EMG

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Cannot close Excel with WIN32OLE
Posted: Fri Jan 04, 2008 02:55 PM
I went back and looked at my test prg's and I could not find the one in question so I created one. At first it worked like you said and what I thought originally. Then I got to thinking about how this problem came up. Then I recall that the problem showed up when the function was still running or the variable was a static.


FUNCTION MAIN()
   LOCAL lRunTest := .t.
   LOCAL oExcel, oSheet
   clear screen
   do while lRunTest
      @ 10, 0 say 'Run Excel Test ' get lRunTest picture 'y'
      read
      if lastkey() = 27
         exit
      endif
      if lRunTest
         @ 20, 0
         // This does not work
         // even though you tell excel to quit it is still
         // running until variable gets reset.
         oExcel = CREATEOBJECT( "Excel.Application" )
         oExcel:quit()
         @ 20, 0 say 'Ok now check with Task Manager'
         wait
         // Works if you run in function that releases variable
         // or you release variable yourself
         oExcel := nil
         TestExcel()
         @ 20, 0 clear
         @ 20, 0 say 'Ok now check Task Manager again'
      endif
   enddo
RETURN( nil )

FUNCTION TestExcel()
   LOCAL oExcel, oSheet
   oExcel = CREATEOBJECT( "Excel.Application" )
   oExcel:quit()
RETURN( nil )
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Cannot close Excel with WIN32OLE
Posted: Fri Jan 04, 2008 03:06 PM

I forgot to mention that when you check in the task manager, you have to look under the Processs tab. It is not in the Applications tab.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Cannot close Excel with WIN32OLE
Posted: Fri Jan 04, 2008 04:39 PM

This is perfectly normal as the automatic destructor is called when the variable exits the scope. It's not a problem at all.

EMG

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Cannot close Excel with WIN32OLE
Posted: Fri Jan 04, 2008 04:47 PM

It was a problem for the person I was helping some time ago because he was using a prg wide static variable. The person in this thread mentioned that Excel was still running so without seeing how he was using the variable I wanted to make sure the variable lost the connection with Excel.

Have a great day. :)

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Cannot close Excel with WIN32OLE
Posted: Fri Jan 04, 2008 06:04 PM

Ok, understood.

EMG

Continue the discussion