Hi Robert,
FoxPro exports to version 2.1 which I don't think supported multiple sheets.
Try the following replacing the "Test" values with your own:
oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open("C:\Test.XLS")
oExcel.Sheets.Add
oExcel.Sheets("Sheet1").Name = "Print format"
oExcel.Sheets("Test").Select
oExcel.ActiveWorkbook.Save
oExcel.Visible = .T.
>I have a need to EXPORT a table created by a query to EXCEL and target it to SHEET2. The code I'm using is something like this:
>
>SELECT Dsjn.req_date, Dsjn.req_by, Dsjn.job_num, Po_detail.frame_num,;
> Po_detail.code_, Po_detail.quan, Po_detail.fog_proc, Po_detail.fog_prnt,;
> Po_detail.stain, Po_detail.hole_pnch, Po_detail.short_pnts,;
> Po_detail.cut_err, Po_detail.layout, Po_detail.watermk, Po_detail.tear,;
> Po_detail.adv_slp, Po_detail.pnt_malf, Po_detail.color,;
> Po_detail.density, Po_detail.focus, Po_detail.spell, Po_detail.other,;
> Po_detail.comment, Dsjn.priority;
> FROM "dig-shrtv2!dsjn" INNER JOIN "dig-shrtv2!pnt_det" Po_detail ;
> ON Dsjn.job_num = Po_detail.job_num;
> WHERE Dsjn.job_num = gnActiveJobNumber;
> AND Po_detail.job_num = gnActiveJobNumber;
> ORDER BY Dsjn.job_num, Dsjn.priority;
> INTO TABLE porequest.dbf
>EXPORT TO dporeq.xls XLS
>
>Is there anyway to modify the last statement to make it export to
>SHEET2 on the spreadsheet? My objective is then to create a macro in EXCEL that will 'peg' the fields in SHEET2 to to a printable version in SHEET1, and automatically print it to a specific printer.
>
>Any ideas?
>Thanks in advance !
>Bob