Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass an array to MS Excel with automation
Message
 
To
03/09/2002 12:41:19
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00696285
Message ID:
00696348
Views:
11
>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()
.....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform