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

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

Postby demont frank » Tue Jan 01, 2008 2: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 :

Code: Select all  Expand view
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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby demont frank » Tue Jan 01, 2008 2:51 pm

Little corection : excel ask to save , when yes it is closed
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Kleyber » Tue Jan 01, 2008 4: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
User avatar
Kleyber
 
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

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

Postby Enrico Maria Giordano » Tue Jan 01, 2008 6:42 pm

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

oExcel:Quit()

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

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

Hello, from Germany

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 96 guests