[Tip]: Setting focus to Excel

[Tip]: Setting focus to Excel

Postby hua » Thu Apr 16, 2009 8:03 am

I don't know how technically accurate or efficient this is but it's what I've tried and so far worked for me.

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
 
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests