>*Use APIs to embed excel on a top level form >*Excel becomes a child of the form window by SetParent API. >*this works but causes many new problems......... > >Publi yfrm >yfrm=Newobject("oexcel") >yfrm.Show >Read Events >Retu >* >Define Class oexcel As Form > Height = 439 > Width = 707 > AutoCenter = .T. > ShowWindow=2 > Caption = "Embed excel on a form" > Name = "Form1" > > Add Object command2 As CommandButton With ; > Top = 405, ; > Left = 228, ; > Height = 27, ; > Width = 156, ; > Caption = "Excel file....", ; > Name = "Command2" > > Procedure Load > Declare SetParent In user32 Integer hWndChild, Integer hWndParent > Declare Integer SetWindowPos In User32 ; > integer Wnd_handler, Integer Window_Order, ; > integer X1, Integer Y1, Integer X2, Integer Y2, Integer wFlags > Declare Long FindWindow In Win32API ; > STRING lpClassName; > ,String lpWindowName > Endproc > > Procedure Destroy > loExcel=Null > Release loExcel > Clea Events > Endproc > > Procedure command2.Click > Local loExcel,loWorkBook > loExcel = Createobject('excel.application') > lcFile = Getfile('xls|xslx') > If Empty(m.lcFile) Or ! Inlist(Lower(Justext(m.lcFile)),"xls","xlsx") > Return .F. > Endi > loWorkBook = loExcel.Workbooks.Add(m.lcFile) > oCaption=loExcel.Caption > Excel_hwnd=FindWindow(Null,oCaption) >* messagebox(trans(oCaption +" "+trans(Excel_hwnd)),0+32+4096,'',1200) > If !Excel_hwnd=0 > SetParent(Excel_hwnd, Thisform.HWnd) > SetWindowPos( Excel_hwnd,0,0,0,Thisform.Width-1,Thisform.Height-1,64) > Else > Messagebox("fails",16+4096) > Endi > > loExcel.Visible = .T. > Endproc > >Enddefine >* >*-- EndDefine: oexcel >Dear Yousfi Benameur,