>i'm havin troubles using a table to sent to excel 5.0 im usin vfp3.0 and
>when i do the ole the excel file it close.
This is code sample how to move data from VFP table to excel workbook:
local nAnswer,cFilename,nExcel,lErrorflag,cError
local array aErrorinfo(7)
select tmpReport9
nAnswer=messagebox("Open File in Excel Format Right Now?",4+32,oApp.msgtitle)
if nAnswer=6
cError=on("error")
if type("thisform.oExcelapp")<>"O"
thisform.excelcount=1
on error lErrorflag=.t.
thisform.oExcelapp=createobject("Excel.Application")
if lErrorflag=.t.
on error &cError.
=messagebox("Cannot Launch Excel!",0+16,oApp.msgtitle)
return
endif
thisform.oExcelapp.visible=.t.
thisform.oeWorkbook=thisform.oExcelapp.workbooks
if lErrorflag=.t.
on error &cError.
=messagebox("Cannot Open Excel Workbook!",0+16,oApp.msgtitle)
return
endif
else
thisform.excelcount=thisform.excelcount+1
endif
cFilename=sys(5)+sys(2003)+"\upts"+alltrim(str(thisform.excelcount))+".xls"
set safety off
copy to &cFilename. type xl5
set safety on
thisform.oeWorkbook.open(cFilename)
if lErrorflag=.t.
on error &cError.
=aerror(aErrorinfo)
=messagebox("Cannot Open Excel File! "+aErrorinfo[2]+chr(13)+aErrorinfo[3],0+16,oApp.msgtitle)
return
endif
return
endif
nAnswer=messagebox("Save File in Excel Format?",4+32,oApp.msgtitle)
if nAnswer<>6
return
endif
cFilename=putfile("Excel File","upts","xls")
if empty(cFilename)
return
endif
copy to &cFilename. type xl5
=messagebox("File Has Been Saved!",0+48,oApp.msgtitle)
Edward Pikman
Independent Consultant