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
Title:
Execl & win32API GetForgroundWindow
Miscellaneous
Thread ID:
00365075
Message ID:
00365075
Views:
107
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
Eddie McCandless
Next
Reply
Map
View

Click here to load this message in the networking platform