>*Form.load >DECLARE LONG FindWindowA IN WIN32API STRING class, STRING title > >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 > >*Form.Init >thisform.AddProperty("oExcel",.NULL.) >thisform.AddProperty("oExcelWindowHandle",0) >thisform.AddProperty("units_fox2ole",1) > >*Form.Unload >SetParent(thisform.oExcelWindowHandle,0) >IF TYPE("thisform.oExcel")="O" AND NOT ISNULL(thisform.oExcel) > thisform.oExcel.quit() >ENDIF >thisform.oExcel=null > >*Form.Resize >WITH this.command1 > .top = this.height - .height -2 >ENDWITH > >IF TYPE("thisform.oExcel")="O" AND NOT ISNULL(thisform.oExcel) AND ; > thisform.oExcel.visible > WITH thisform.oExcel > .visible=.f. > .width=thisform.Width /thisform.units_fox2ole > .height=thisform.Command1.Top /thisform.units_fox2ole > .left = -5 > .Top = 0 > .visible=.t. > ENDWITH >ENDIF > >*Formk.Command1.Click. >* Modify the procedure as needed to deal with many files open, etc. > >=ADIR(aa,"c:\*.xls") >IF TYPE("thisform.oExcel")#"O" OR ISNULL(thisform.oExcel) > > thisform.oExcel = CREATEOBJECT("Excel.Application") > > WITH thisform.oExcel > .DisplayAlerts = .f. > .Visible=.t. > > thisform.oExcelWindowHandle = FindWindowA(NULL, .Name) > > SetParent(thisform.oExcelWindowHandle,thisform.HWnd) > setWindowPos(thisform.oExcelWindowHandle,0,0,0,; > thisform.width,; > thisform.command1.top,; > 0) > > thisform.oExcel.Workbooks.Open("c:\"+aa[1]) > thisform.units_fox2ole = thisform.width/.width > > endwith >ENDIF > >>