Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel cell reference
Message
De
08/06/2007 11:22:27
 
 
À
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:
01231609
Vues:
13
>>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()
>
See Fred's post regarding .Address which eliminates the need for a second cell reference. This is more consistent with my mental paradigm. Regarding the reference to oSheet, of course that's the way to do it. It's just that your first example wasn't clear as to the path that had been established.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform