Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bringing Excel window forward
Message
From
23/10/2019 14:45:25
 
 
To
23/10/2019 14:43:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01671640
Message ID:
01671646
Views:
60
>Hi Rick,
>How do I get an hwnd handle to an Excel object? I got an error loWorkbook.HWnd. Do I have to do another function call to get the handle from the OS?

The example I included in my OP worked for me from the command prompt. Make sure you're using the root Excel.Application object, and not an object reference from something deeper. You may also be able to reference it contextually from a lower object using loWorkbook.parent.parent.HWnd or something along those lines. Never tried it.

>>>Hi,
>>>
>>>Can someone post code as to how to bring an Excel window forward using api calls? My current code creates an Excel document, inserts all the data and then uses .Activate() which just activates it on the toolbar so that it is flashing - it does not actually bring it forward. I figure Win api calls would need to be used to do this.
>>>
>>>I have looked in the VFP Office automation book but the constants used are old and figure someone might have a nice function to do this.
>>
>>
lo = CREATEOBJECT("Excel.Application")
>>lo.visible = .t.
>>
>>DECLARE INTEGER BringWindowToTop IN WIN32API INTEGER hWnd
>>DECLARE INTEGER ShowWindow       IN WIN32API INTEGER hWnd, LONG nCmdShow
>>
>>ShowWindow(lo.HWnd, 1)
>>BringWindowToTop(lo.HWnd)
>>
>>Works with any window you can get an HWnd to (thisForm, _screen, etc.).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform