Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Execl & win32API GetForgroundWindow
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00365075
Message ID:
00365125
Views:
26
You don't say what version of VFP you are using but if it is 6.0 you could use the VFPCOM.DLL to bind a custom object to the Excel.Application object and have your code execute when the Excel window is deactivated.
DEFINE CLASS AppEvents AS custom

< snipped>
	PROCEDURE WindowActivate(Wb,Wn)
	* Add user code here
	ENDPROC


	PROCEDURE WindowDeactivate(Wb,Wn)
	* Add user code here
	ENDPROC
< snipped >
ENDDEFINE
HTH.

>I am creating an object for Excel using Automation and am trying to determine when the user close/quits excel.
>
>I have it working for Word but I am having problems getting it working for Excel. Below is what works for Word.
>
>* --- Define WinApi Functions
>DECLARE integer GetForegroundWindow in WIN32API
>DECLARE short IsWindow in WIN32API integer
> oWord = CreateObject("Word.Application")
> oWord.Visible = .T.
> oWord.Activate()
> lnWordWindow = GetForegroundWindow() && Save word window handle
>
> If Type("oWord") = "O" And Not IsNull(oWord)
> && Loop while Word Window Active
> Do While IsWindow(lnWordWindow) # 0
> EndDo
> && User has Closed Word Session
>
> Release oWord
> Release oDocument
> EndIf
>
>Thanks for the help
>
>Here is what I am trying for Excel.
>
>
>DECLARE integer GetForegroundWindow in WIN32API
>DECLARE short IsWindow in WIN32API integer
>
> oExcel = CreateObject("Excel.Application")
> oExcel.Visible = .T.
> lnExcelWindow = GetForegroundWindow() && Save excel window handle
>
> If Type("oExcel") = "O" And Not IsNull(oExcel)
> Do While IsWindow(lnExcelWindow) # 0
> EndDo
> Release oExcel
> EndIf
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform