Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Re: VFP Excel Automation
Message
From
04/04/2016 07:46:09
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
04/04/2016 05:54:57
Sonny Tabano
Trams Printwork, Inc.
Mabalacat, Philippines
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01634243
Message ID:
01634253
Views:
71
I have the impression that you want to generate formulae of the type "A1". That's way too complicated (what's Z + 1?). It's much easier to use numbers, both for rows and columns. For example:
loSheet.Cells(lnRow, lnCol).Value = ...
The above is to insert a value, but the coordinates are numbers.

In the case of formulae:
* Record a macro
* Edit the formula
* Save it
* Stop recording
Look at the resulting macro; it will show you the formula using numbers. Instead of "formula=..." you will be using "formulaR1C1=..."


>Hi,everyone,
>
>need some help on the following automation codes
>
>
>1. This one works ok
>
>
>lcASCIIcode=65
>rows = 1
>cols = 1
>
>Do while .not. eof()
>
>    WITH oExcel
>            .Cells(rows,Cols).formula = "=SUM("+CHR(65)+LTRIM(str(7))+":"+CHR(65)+LTRIM(str(rows))+")"     & & Result is =sum(A7:Axx)  
>    Endwith 
>    skip
>    cols = cols + 1
>    rows = rows + 1
>
>    lcASCIIcode= lcASCIIcode + cols
>enddo
>
>
>2. But when i tried to substitute the chr(66) into the following codes below so that Chr(66) would become chr(67) for the next loop and chr(68) on the next loop , it resulted into errors
>(expected results are from =sum(A7:Axx) then to =sum(B7:Bxx) ,  then to =sum(C7:Cxx) .and so on......)
>
>lcASCIIcode=65
>rows = 1
>cols = 1
>
>Do while .not. eof()
>
>    WITH oExcel
>           .Cells(rows,Cols).formula = "=SUM("+CHR(lcASCIIcode)+LTRIM(str(7))+":"+CHR(lcASCIIcode)+LTRIM(str(rows))+")"
>    Endwith 
>    skip
>    cols = cols + 1
>    rows = rows + 1
>
>    lcASCIIcode= lcASCIIcode + cols
>   
>enddo
>
>I also tried this one but doesnt work also
>  .Cells(rows,Cols).formula = "=SUM("+CHR(STR(lcASCIIcode))+LTRIM(str(7))+":"+CHR(STR(lcASCIIcode))+LTRIM(str(rows))+")"
>
>
>
>Any help is highly appreciated,
>
>thanks in advance
>
>
>Sonny
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)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform