FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Excel window to the foreground
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Excel window to the foreground
Posted: Thu Dec 24, 2020 11:40 AM

Hi,

Several Excel documents are open on the computer. From my program, I open Excel (CreateObject), create a new document, and want to bring it to the foreground. How can I do this ?

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Excel window to the foreground
Posted: Thu Dec 24, 2020 01:43 PM
I use :

export xBrowse to excel
and open the result on buttonaction :

Code (fw): Select all Collapse
@ 5, 720 BTNBMP oBBtn[17] OF oBar ;
SIZE 110, 32 PIXEL ;
BORDER ;
PROMPT " &Excel " ;
FILENAME c_Pfad1 + "Excel.Bmp" ;
ACTION ( oBrw:ToExcel(), ;
             SetFocusAfter(FindWindow( "XLMAIN", 0 ) ) ) ;
FONT oFontSys  ;
LEFT


[/code]regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Excel window to the foreground
Posted: Thu Dec 24, 2020 03:25 PM

I'm not editing a specific document, but opening a new one. So FindWindow() won't go

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Excel window to the foreground
Posted: Thu Dec 24, 2020 03:53 PM
Did you try with
Code (fw): Select all Collapse
oExcel:Visible = .T.
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 137
Joined: Mon Oct 22, 2012 04:43 PM
Re: Excel window to the foreground
Posted: Thu Dec 24, 2020 04:02 PM
Try
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()
   local ownd
   define window ownd
   
   activate window ownd on paint excel()
   
return nil 

function excel()
   local oExcel := CreateObject( "excel.application" )
   local oBook  := oExcel:Workbooks:Add()
   local oSheet := oBook:Worksheets( 1 ) 
   local hwnd

   oSheet:Range( "A1" ):Value = "Last Name"
   oSheet:Range( "B1" ):Value = "First Name"
   oSheet:Range( "A1:B1" ):Font:Bold = .T.
   
   oSheet:Range( "A2" ):Value = "Doe"
   oSheet:Range( "B2" ):Value = "John"

   oExcel:Visible = .T.
 
   hWnd:=oExcel:hWnd
   ShowWindow(hWnd, 3)
   BringWindowToTop(hWnd)

return nil
Regards



Ing. Anton Lerchster
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Excel window to the foreground
Posted: Thu Dec 24, 2020 04:51 PM
hWnd:=oExcel:hWnd


This is what you need. Thanks !

Continue the discussion