R: ActiveX currency type (MAPI)

Luca Calderano calderano at sgaspa.it
Mon Jun 16 05:50:34 EDT 2003


This is the way you can display the currency data type

temp = float((long(Rst.Fields.Item(i).Value[1])&0xFFFFFFFFL) |
(long(Rst.Fields.Item(i).Value[0])<<32)) /1e4
locale.format('%.2f',temp, 1)



Luca Calderano


-----Messaggio originale-----
Da: python-list-admin at python.org
[mailto:python-list-admin at python.org]Per conto di Andrew Henshaw
Inviato: lunedi 16 giugno 2003 11.32
A: python-list at python.org
Oggetto: Re: ActiveX currency type (MAPI)


Bradley Schatz wrote:

> I am accessing through MAPI.Session, custom properties of outlook forms
> that reside in Exchange.
>
> I am using the methods described comprehensively on the CDOLive site
> http://www.cdolive.com/cdo10.htm , specifically the Fields interface.
>
> My problem is that for a Field that is of type Currency (the equivalent
> type of vbCurrency) I am getting a return of a tuple - for example for a
> price of $ 21,000,000 I get the tuple [4, -474836480]
>
> According to the CDOlive documentation, the value should be an 8byte
> integer scaled by 1000.
>
> Has anyone any suggestions on how to coerce win32com to unmarshal this
> type correctly?
>
> Thanks,
>
> Bradley

Not sure if this is the best way, but it should work.

import struct

hi, lo = (4, -474836480)
value = struct.unpack('q', struct.pack('II', lo, hi))
print value

>>
21000000000

--
http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list