>Anyone know how to set the value of a range object in Excel from an array in VFP?
>I made a wrapper class 'icgxl' to make my life easier. oMyXl.oleApp corresponds to the Excel.Application object reference.
>The commented line at the bottom gets a syntax error.
>With further messing around, I found out that if I do this:
>
>oMyXl.oleApp.Range(lcRangeString).Select
>
>
>1st, then it does not get a syntax error, but instead, fills the range with all values of '10001'
>
>
>LOCAL lnRowCount, lnColumnCount, lcRangeString
>
>USE l:\boowned\surface\main0001 IN 0 ALIAS main
>
>SELECT wcode, tnum, tname, st, county, acct ;
>FROM main INTO cursor mysheet;
>WHERE class NOT like 'D__';
>AND class NOT like 'N__'
>
>SELECT mysheet
>lnColumnCount = FCOUNT()
>lnRowCount = RECCOUNT()
>lcRangeString = 'A1'+':'+getletter(lnColumnCount)+ALLTRIM(STR(lnRowCount))
>COPY TO ARRAY myarray
>
>DEBUG
>SUSPEND
>
>oMyXl = CREATEOBJECT("icgxl")
>oMyXl.Visible(.T.)
>oMyXl.CreateSheet(" ")
>oMyXl.oleApp.Worksheets("sheet1").Activate()
>*oMyXl.oleApp.Range(lcRangeString).Value = @myarray
>
Jim,
I doubt that you can do it this way because of differences between 'arrays' in VB and in VFP. Instead try something like this:
SELECT wcode, tnum, tname, st, county, acct ;
FROM main INTO cursor mysheet;
WHERE class NOT like 'D__';
AND class NOT like 'N__'
_VFP.Datatoclip(,,3)
ObjExcel= CREATEOBJECT("Excel.Application")
ObjExcel.DisplayAlerts = .f.
ObjExcel.Workbooks.add()
ObjExcel.Range("a1").Select
ObjExcel.ActiveSheet.Paste()
.....