Excel window to the foreground

Excel window to the foreground

Postby Natter » 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 ?
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Excel window to the foreground

Postby ukoenig » Thu Dec 24, 2020 1:43 pm

I use :

export xBrowse to excel
and open the result on buttonaction :

Code: Select all  Expand view

@ 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 :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Excel window to the foreground

Postby Natter » Thu Dec 24, 2020 3:25 pm

I'm not editing a specific document, but opening a new one. So FindWindow() won't go
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Excel window to the foreground

Postby Marc Vanzegbroeck » Thu Dec 24, 2020 3:53 pm

Did you try with
Code: Select all  Expand view
oExcel:Visible = .T.
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Excel window to the foreground

Postby alerchster » Thu Dec 24, 2020 4:02 pm

Try
Code: Select all  Expand view
#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
User avatar
alerchster
 
Posts: 93
Joined: Mon Oct 22, 2012 4:43 pm

Re: Excel window to the foreground

Postby Natter » Thu Dec 24, 2020 4:51 pm

hWnd:=oExcel:hWnd


This is what you need. Thanks !
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 38 guests