Here's the scenario.
- Code: Select all Expand view
.
.
oExcel:ActiveWorkBook:SaveAs(cFullPath)
oExcel:DisplayAlerts := .t.
msginfo("Data has been saved at"+CRLF+cFullPath)
SetFocusAfter(FindWindow( "XLMAIN", 0 ))
oExcel:visible := .t.
.
.
Based on snippet above, you can see after exporting some data into an Excel file, I wished to inform the user the full path of where it was saved. After that was done I'd like to bring Excel into focus. After trying a couple of ways, SetFocusAfter() works as I need it to and this is how it was coded:
- Code: Select all Expand view
function SetFocusAfter(hWnd)
local oTimer
define timer oTimer interval 500 of oWnd ;
action (BringWindowToTop(hWnd), oTimer:DeActivate())
activate timer oTimer
return Nil