I didn't know you can insert directly into the Excel object; I thought you had to select a spreadsheet first.
Try to create a variable for the current spreadsheet, as in my article on Excel automation -
http://www.utmag.com/wconnect/wc.dll?9,7,10,1562 . Then, from there, you can go "up" to the workbook, and select the next sheet, as in my example.
On the other hand, you might keep an object for the current workbook in the first place.
>Hi Hilmar,
>
> it gives me the same result," Unknown Member oSheet".
>
>
> ole = CreateObject("Excel.Application")
> With ole
> nrow=7
> nrecno=1
> Select cur_inv
> SCAN
> .Cells(nrow,1).Value=cur_inv.invdate
> .Cells(nrow,2).Value=cur_inv.icsno
> .Cells(nrow,3).Value=cur_inv.loctid
> nrow = nrow+1
> nrecno = nrecno+1
> IF nrecno=60 THEN
> nrow=7
> nrecno=1
>
> with This
> local loWorkbook
> loWorkbook = .oSheet.Parent
> .nActiveSheet = .nActiveSheet + 1
> if This.nActiveSheet > loWorkbook.Sheets.Count
> loWorkbook.Sheets.Add(NULL, loWorkbook.Sheets(loWorkbook.Sheets.Count))
> .oSheet = loWorkbook.ActiveSheet
> else
> .oSheet = loWorkbook.Sheets(This.nActiveSheet)
> endif
> .nRow = 1
> .nCol = 1
> endwith
>
> ENDIF
> SELECT cur_inv
> ENDSCAN
>
>EndWith
>
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)