[Q] win32com/Excel

Robin Becker robin at jessikat.fsnet.co.uk
Sun Sep 1 05:23:23 EDT 2002


In article <lbzsn0uw5cr.fsf at aqualene.uio.no>, Rolf Marvin Bøe Lindgren
<roffe at aqualene.uio.no> writes
>I would like to emulate this Visual Basic statement from Python, using
>Com:
>
>        Range(Range("A1"), ActiveCell.SpecialCells(xlLastCell)).Select
>
>this statement selects the active worksheet (which is, incidentally,
>not similar to UsedRange).  
>
>any clues?  
>
>thank you,
from win32com.client import Dispatch
from win32com.client import constants
xl = Dispatch("Excel.Application")
AB = xl.ActiveWorkbook
AS = AB.ActiveSheet
AW = xl.ActiveWindow
R = AS.Range('A1',AW.ActiveCell.SpecialCells(constants.xlLastCell))
print AB.Name, AS.Name, R
-- 
Robin Becker



More information about the Python-list mailing list