FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to end oExcel := TOleAuto():New( "Excel.Application" ) ?
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM

How to end oExcel := TOleAuto():New( "Excel.Application" ) ?

Posted: Sat Apr 24, 2010 06:06 AM

Hi,
oExcel := TOleAuto():New( "Excel.Application" )
oExcel:WorkBooks:Open(ALLTRIM(cfile))
oSheet := oExcel:ActiveSheet()
oExcel:quit()

but excel.exe still runnning in memory.
Thanks !
Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM

Re: How to end oExcel := TOleAuto():New( "Excel.Application" ) ?

Posted: Sat Apr 24, 2010 06:40 AM
Dear Mr.Shuming Wang

Your code is working fine for me
Code (fw): Select all Collapse
#include "fivewin.ch"

FUNCTION MAIN

  cFile:="c:\users\anser\desktop\Test.xls"
  MsgInfo("About to create Excel object")
  
  oExcel := TOleAuto():New( "Excel.Application" )
  oExcel:WorkBooks:Open(ALLTRIM(cfile))
  oSheet := oExcel:ActiveSheet()
  
  MsgInfo("Open and Check Task Manager, you should find EXCEL.EXE in the Processes List")
  
  oExcel:quit()
  
  MsgInfo("Excel is closed. After you close this MsgBox,";
          "you will not find EXCEL.EXE in the Task Manager, Processes List")
   
RETURN NIL


Tested using Office 2007. It is also better to do a oWorkBook:Close() before the oExcel:Quit()

Code (fw): Select all Collapse
oWorkBook:=oExcel:WorkBooks:Open(ALLTRIM(cfile))
oWorkBook:Close()
oExcel:Quit()


I suggest you to check whether any previously opened Excel instances are still running in your PC, may be that could be the reason. :-)

While trying to creating the excel object, It is always better to code as given below

Code (fw): Select all Collapse
TRY
    oExcel = GetActiveObject( "Excel.Application" )
CATCH
    TRY
        oExcel = CreateObject("Excel.Application")
    CATCH
        MsgInfo("It seems that Excel is not installed on this PC. You need Excel to continue further")
        Return .F.
    END
END

Regards
Anser
Posts: 603
Joined: Sun May 04, 2008 08:44 PM

Re: How to end oExcel := TOleAuto():New( "Excel.Application" ) ?

Posted: Sat Apr 24, 2010 06:47 PM

It´s work fine to me.

oExcel := TOleAuto():New( "Excel.Application" )
oExcel:WorkBooks:Open(ALLTRIM(cfile))
oSheet := oExcel:ActiveSheet()
oExcel:quit()

oExcel:=Nil
Release All

:D

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: How to end oExcel := TOleAuto():New( "Excel.Application" ) ?

Posted: Sun Apr 25, 2010 09:44 AM
lailton.webmaster wrote: oExcel:quit()

oExcel:=Nil
Release All


oExcel:quit() is more than enough.

EMG

Continue the discussion