[python-win32] Setting false in Excel via COM
Frank Jacques
kwa@crf-vogler.com
Thu, 25 Apr 2002 15:34:27 +0200
Hi Tim,
I'm the author of the question and i apologize i haven't posted
back the response that Mark Hammond made from an e-mail i sent him.
By the way, thanks very much Mark, this hints save me from an hybrid
python/VB macro solution... (bah !)
The e-mail:
---------------------------------------------------
Subject: RE: [Fwd: PyTrue and PyFalse or How to pass a VT_BOOL to excel]
Date: Fri, 11 Jan 2002 09:39:26 +1100
From: "Mark Hammond" <mhammond@skippinet.com.au>
To: <kwa@crf-vogler.com>
Note the new email address:
You should be able to pass zero - the literal 0.
PyTrue is "internal", but you can force it by passing an expression = eg,
1==0.
false = 1==0
Worksheet.PageSetup.FitToPagesTall(false)
but it is *very* rare that this is necessary.
Mark.
> -------- Original Message --------
> From: Frank Jacques <kwa@crf-vogler.com>
> Subject: PyTrue and PyFalse or How to pass a VT_BOOL to excel
> To: MarkH@activestate.com
>
>
> Hi,
>
> I've searched the web and haven't seen anything like PyTrue or
> PyFalse in Python. So, my problem is that i need to pass to
> excel's Worksheet.PageSetup.FitToPagesTall a False value.
>
> How can i achieve that ?
>
> Thanks a lot for any hint. Thanks anyway for your very great work
> on python and win32. You make my work a child play fairly often !
>
> Best regards,
> Frank
------------------------------------------
So, this hint also works very well in this case.
Hope the python debat about introducing a boolean type will raise
a consensus soon...
And thanks very much for your responses, Tim and Mark.
Regards,
Frank
Tim Golden wrote:
> I've had a look round and haven't seen anybody else's answer to this, only an unanswered question last December.In Excel, if you want to set, say, the
> ActiveSheet.PageSetup.Zoom value to False (which seems to be the equivalent of deselecting its radio button on the dialog box) then you need to import
> pywintypes and use its FALSE value, so:ws.PageSetup.Zoom = pywintypes.FALSESetting the Zoom value to 0 (zero) or any integer value less than 10 (ten) raises
> an exception. In this case, setting Zoom to pywintypes.TRUE also raises an exception, but this is presumably because the concept is not valid in this
> context.This seems to work, but I'd love to know why.TJG
>
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star Internet. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________