FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Ole Excel : closing aplication with sendmessage(hwnd,16)
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM

Ole Excel : closing aplication with sendmessage(hwnd,16)

Posted: Tue Jan 01, 2008 02:48 PM
Hello,

I try to use

oExcel := CreateObject( "Excel.Application" ) , followed with

oExcel:WorkBooks:Add()
oAs := oExcel:ActiveSheet()

After making it visible (oExcel:Visible := .T.) , the user can close aplication or return to the aplication without closing it.

I noticed that excel is executed with caption .... MAP1 ...

Next code can detect that excel is not closed , but closing it fails :

hWnd := FINDWND( "MAP1" )

IF !EMPTY( hWnd )
  SENDMESSAGE( hWnd, 16 )
  //CloseWindow(hWnd)
END


#define GW_HWNDNEXT  2
#define GW_CHILD     5

FUNCTION FINDWND( cTitle )

 LOCAL hWnd := GETWINDOW( GETDESKTOPWINDOW(), GW_CHILD )

WHILE hWnd != 0
  IF UPPER( cTitle ) $ UPPER( GETWINDOWTEXT( hWnd ) )
    RETURN hWnd
  ENDIF
  hWnd = GETWINDOW( hWnd, GW_HWNDNEXT )
ENDDO

RETURN NIL


How can excel be closed ?

Must the object oExcel released ? How

Frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM

Ole Excel : closing aplication with sendmessage(hwnd,16)

Posted: Tue Jan 01, 2008 02:51 PM

Little corection : excel ask to save , when yes it is closed

Posts: 581
Joined: Tue Oct 11, 2005 11:28 AM

Ole Excel : closing aplication with sendmessage(hwnd,16)

Posted: Tue Jan 01, 2008 04:47 PM

Hi Frank,

I would do at the end of function:

oExcel:=NIL

Best regards and a Happy New Year

Kleyber Derick



FWH / xHb / xDevStudio / SQLLIB
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Ole Excel : closing aplication with sendmessage(hwnd,16)

Posted: Tue Jan 01, 2008 06:42 PM

You have oExcel. So you can use it to close Excel:

oExcel:Quit()

EMG

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

Ole Excel : closing aplication with sendmessage(hwnd,16)

Posted: Tue Jan 01, 2008 06:42 PM
Kleyber wrote:Hi Frank,

I would do at the end of function:

oExcel:=NIL

Best regards and a Happy New Year


No, it is not needed.

EMG
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Hello, from Germany

Posted: Tue Jan 01, 2008 07:40 PM

Yust have a look at my sample < Excel-Matrix >
you can download it from

http://pflegeplus.com/fivewin
or have a look at forum => utilities

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.

Continue the discussion