Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel cell reference
Message
De
21/06/2007 11:14:04
 
 
À
07/06/2007 21:04:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01230317
Message ID:
01234723
Vues:
8
>>Then I would expect
>>
>>oexcel.Range(oexcel.activesheet.cells(7,3)).Select
>>
>>would work, but it doesn't.
>
>I don't know; I always used .Range on a Sheet object. Also, it requires TWO cells - for instance, one for the upper-right, and one for the lower-left corner of the rectangle you want to select. To avoid repeating a long string several times, I would use (assuming you want a single cell):
>
>
>with oExcel.ActiveSheet
>  .Range(.Cells(7,3), .Cells(7,3)).Select()
>endwith
>
>
>Of course, in this case, it would be easier to just select a single cell - but for generic code, where you don't know the size of the range in advance, this should still work.
>
>Also, of course you can expand the "with" in every case:
>
>
>with oExcel.ActiveSheet
>  oExcel.ActiveSheet.Range(oExcel.ActiveSheet.Cells(7,3),;
>   oExcel.ActiveSheet.Cells(7,3)).Select()
>endwith
>
>
>However, since most of the time you will be working a lot with the same sheet, I would create a separate object for the sheet, to avoid unnecessary repetition:
>
>
>loSheet = loExcel.ActiveSheet
>...
>loSheet.Cells(...).Value = ...
>loSheet.Range(loSheet.Cells(7,3), loSheet.Cells(7,3)).Select()
>
I'm still trying to get a grip on your technique. Suppose you captured a cell reference as in
cell1 = .activecell
then moved the cursor somewhere else and
cell2 = .activecell
Cell1 and cell2 now define the boundries of a range. How would you specify the sum of that range?
* move again and . . . 
.selection.value = '=sum(' + cell1 ':' cell2 + ')'    && this is the idea
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform