[python-win32] Excel -- Range() not working

Gerald Reeder greeder221 at gmail.com
Wed Apr 1 01:18:30 CEST 2009


Hello,

I'm trying to get values from a non-contiguous range, specifically
"E5:E10,E35"

Range("E5:E10,E35").Value -- only returns the values for "E5:E10", ignoring
"E35"
Range("E5:E10,E35").Address -- however returns "E5:E10,E35"
 Range("E5:E10,E35").Count -- returns 7, which is correct

I'm early-binding and using Python 2.6 and Pywin2.6.1

from win32com.client import Dispatch

    xl = Dispatch('Excel.Application')
    xl.Visible = 0
    xl.DisplayAlerts = 0
    xl.Workbooks.Open(xl_file)
    wrkbk = xl.ActiveWorkbook
    sht = wrkbk.Worksheets(1)
    print sht.Range("E5:E10,E35").Value
    print sht.Range("E5:E10,E35").Address
    wrkbk.Close()
    xl.Quit()

Any ideas? I've searched the complete archive and I've read Mark and Andy's
(excellent) book.
A VBA Macro works with this Range syntax.

Thank you,
JR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20090331/d2556f2c/attachment.htm>


More information about the python-win32 mailing list