how to operate the excel by python?

Simon Brunning simon.brunning at gmail.com
Mon Jun 20 10:42:36 CEST 2005


On 6/17/05, Hughes, Chad O <chad.hughes at pnl.gov> wrote:
>  
> I have posed a more complete answer to your question, however, it is quite a
> large and It is awaiting approval.  For now, xlRight = -4152.  You can find
> this out by opening up Excel and typing the ALT-F11 combination.  From there
> use the ObjectBrowser.  For example if you type in the word "xlRight"  you
> will see that it is equal to -4152. 

I've had problems with these constants differing between versions
before, so I don't recommend hard coding them. (This was in Word
rather than Excel, AFAICR, but if Bill can do it to us once, he can do
it to us twice.) Luckily, you can use the constants by name:

PythonWin 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au)
- see 'Help/About PythonWin' for further copyright information.
>>> import win32com.client
>>> excel = win32com.client.gencache.EnsureDispatch("Excel.Application")
>>> win32com.client.constants.xlRight
-4152

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list