ObjExcel= CREATEOBJECT("Excel.Application")
*ObjExcel.DisplayAlerts = .f.
wb = ObjExcel.Workbooks.add()
ConnectionString="ODBC;DSN=Visual FoxPro Tables Download;UID=;PWD="
sqlquery="SELECT * from c:\netelite\lctrans1"
ObjExcel.ActiveSheet.QueryTables.Add(;
ConnectionString,;
ObjExcel.ActiveSheet.Range("A1"),;
sqlquery)
ObjExcel.ActiveSheet.QueryTables(1).BackgroundQuery = .f.
ObjExcel.ActiveSheet.QueryTables(1).Refresh
ObjExcel.ActiveSheet.Range("A1").Select
SET SAFETY OFF
mfileexcel = mfile
IF FILE(mfileexcel)
DELETE FILE &mfileexcel
ENDIF
wb.SaveAs(mfileexcel)
ObjExcel.Quit()
|