Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel cell reference
Message
De
07/06/2007 21:04:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
07/06/2007 15:53:20
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01230317
Message ID:
01231482
Vues:
11
>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()
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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform