Driving Excel from Python

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Thu Jun 29 03:08:27 EDT 2000


Thanks. I'll look into that.

--
Dale Strickland-Clark
Out-Think Ltd, UK
Business Technology Consultants


Alex Martelli <alex at magenta.com> wrote in message
news:8jd51g0j9k at news2.newsguy.com...
> Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> wrote in message
> news:8j7oqn$e9q$1 at supernews.com...
> > (Sorry if this appears more than once. I'm getting errors from news
> server).
> >
> > I'm driving Excel from Python and most of it's working fine except for:
> >
> > >>> xlsh.UsedRange.Address(ReferenceStyle=1)
> > TypeError: call of non-function (type string)
> >
> > xlsh is an Excel Sheet object and I'm trying to get the used range in
RxCx
> > format. However, when I try and specify ANY arguments to the Address
> > property, I get this error message. I've tried both positional and
keyword
> > arguments.
> >
> > I have the Python Win32 book but this this subject is not quite covered
in
> > sufficient depth.
> >
> > Any help appreciated.
>
> For reasons that escape me, .Address doesn't seem to be seen as an
> indexed-property; however, a .GetAddress is also made available that
> does seem to behave as an indexed-property like .Address should.  I
> sort of suspect that this is to let people use .Address, without any
> parenthesis, in the common case where they want to let all arguments
> default.  However, I can't find any docs about this guess of mine.
>
> Anyway, you CAN now call
>
> xlsh.UsedRange.GetAddress(ReferenceStyle=1)
>
> and get the same '$A$1' kind of string that you'd get with
>
> xlsh.UsedRange.Address
>
> since, after all, xlA1, aka 1 (win32com.client.constants.xlA1, too),
> IS the default value for ReferenceStyle.
>
> A further puzzlement, however, is that
>
> xlsh.UsedRange.GetAddress(ReferenceStyle=-4150)
>
> ALSO appears to return the same '$A$1' string too!  BTW, that funny
> -4150 is xlR1C1, aka win32com.client.constants.xlR1C1, who knows
> why.  But anyway, while this does allow accessing the Address indexed
> properties with 'indices' (arguments), this doesn't appear to be
> doing much good at all.  Maybe somebody else understands what's
> going on...?
>
> It does work fine from the Immediate windows in VBA inside Excel:
>     print Sheet1.UsedRange.Address
> $A$1
>     print Sheet1.UsedRange.Address(ReferenceStyle=xlR1C1)
> $A1
>
> but from Python I always get '$A$1'.  Weird...
>
>
> Alex
>
>
>
>





More information about the Python-list mailing list