Cannot close Excel with WIN32OLE

Cannot close Excel with WIN32OLE

Postby ukoenig » Thu Jan 03, 2008 3: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby jacquetph » Thu Jan 03, 2008 4:25 pm

With Fivewin and xharbour, just comment your line oxls:end()
You dont need it anymore .
Good luck
jacquetph
 
Posts: 2
Joined: Sat Sep 08, 2007 1:47 pm

Postby Gale FORd » Thu Jan 03, 2008 5:05 pm

I think what you want is

oExcel:quit()
oExcel := nil
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Enrico Maria Giordano » Thu Jan 03, 2008 6:23 pm

Gale FORd wrote:I think what you want is

oExcel:quit()
oExcel := nil


The last is not needed.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gale FORd » Thu Jan 03, 2008 7: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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

End Excel-Worksheet

Postby ukoenig » 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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Armando » 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
User avatar
Armando
 
Posts: 3209
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gale FORd » Thu Jan 03, 2008 11:53 pm

I did not believe it either. I will put something together tomorrow.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Enrico Maria Giordano » Fri Jan 04, 2008 12:31 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gale FORd » Fri Jan 04, 2008 2: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.


Code: Select all  Expand view
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 )

Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Gale FORd » Fri Jan 04, 2008 3: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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Enrico Maria Giordano » Fri Jan 04, 2008 4: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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gale FORd » Fri Jan 04, 2008 4: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. :)
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Enrico Maria Giordano » Fri Jan 04, 2008 6:04 pm

Ok, understood.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 75 guests