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

Post Reply
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

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

Post by demont frank »

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

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

Post by demont frank »

Little corection : excel ask to save , when yes it is closed
User avatar
Kleyber
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Post by Kleyber »

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

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
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Hello, from Germany

Post by ukoenig »

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.
Post Reply