[python-win32] How to get target of folder shortcuts

2019-03-18 Thread kurt
Hello, I'm trying to get the target filename of windows shortcuts.  The
code below works great for regular shortcuts, but errors out on "folder
shortcuts".  (for what I mean, see:
https://superuser.com/questions/456399/what-different-types-of-shortcut-are-there/639967#639967)

The code below works great for regular .lnk shortcuts, but folder
shortcuts give me:
[...]
persistFile.Load(fname,STGM_READ)
pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)

The quirk with folder shortcuts is they have some DOS attributes set,
which I suspect could be causing me trouble.  Is there, perhaps,
something I need to do to get my IPersistFile to ignore file attributes?

Or is this error a result of something else?

- teh code

def linkinfo(path):
"""
returns (isLink,targetPath)
"""
path=os.path.abspath(path)
targetPath=path
fname=path
isLink=False
desktop=shell.SHGetDesktopFolder()
_,pidl,_=desktop.ParseDisplayName(None,None,path)
shell_item =shell.SHCreateShellItem(None,None,pidl)

attrs=shell_item.GetAttributes(shellcon.SFGAO_LINK|shellcon.SFGAO_FOLDER)
isLink=attrs_LINK>0
isFolder=attrs_FOLDER>0
if isLink and not fname.endswith('URL'):

shellLink=pythoncom.CoCreateInstance(shell.CLSID_ShellLink,None,pythoncom.CLSCTX_INPROC_SERVER,shell.IID_IShellLink)
persistFile=shellLink.QueryInterface(pythoncom.IID_IPersistFile)
if isFolder:
fname=fname+os.sep+'target.lnk'
persistFile.Load(fname,STGM_READ)
targetPath,findData=shellLink.GetPath(0)
return isLink,targetPath
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Dragdrop shell extension?

2018-06-26 Thread Kurt Eilander

Hey all,

I've implemented a file format called .urls which is a plain text file 
containing (guess what) urls.
I've successfully registered it with a python script so it can, when 
clicked, open a new browser windows with all of the urls listed in new tabs.

(Very handy!)

Now, I want to be able to drop handler such that a link dragged from the 
browser (system .url file, basically) onto the .urls file will append 
the new link to those in the list.


I understand that file formats which do this sort of thing register a 
program as a shell extension, but how do I write such a thing to handle 
shell dragdrop in python??


Thanks,
-K

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] playing with scintillacon

2017-12-16 Thread Kurt Eilander

I already had "import win32api".

As for pywintypes27.dll, it is one of four files automatically placed in 
c:\windows\system32 by the installer, which is a pretty sure thing as 
far as being able to find it.  I was getting desperate so I even copied 
it over, AND all the binaries from the 
C:\Python27\Lib\site-packages\pythonwin directory for good measure.  I 
checked the security privileges on all of them and verified that they 
were 64-bit using a PE explorer (ProcessHacker2).


There must be something else I'm missing.

NOTE:
I am basing my code on the example 
C:\Python27\Lib\site-packages\win32comext\shell\demos\servers\shell_view.py 
ScintillaShellView class.  Which is supposed to implement a windows 
explorer preview with scintilla highlighting.


Anyway, when I try and run that full sample, I get a folder created that 
I cannot open.  (Like it's registered correctly, but the code behind it 
is kaput.)   I use NirSoft's shell extension viewer 
(http://www.nirsoft.net/utils/shexview.html), and it tells me it "cannot 
find c:\Windows\system32\pythoncom27.dll". Bafflingly, it IS THERE!  
And, since it is another of the same set of dll's created by the 
installer, I'm wondering if this might be a clue?  Could there be a 
problem with the way the dll's are compiled and/or installed??


On 12/15/2017 3:47 PM, eryk sun wrote:

On Fri, Dec 15, 2017 at 9:10 PM, Kurt Eilander <web...@totalrewind.com> wrote:

Ok, I found scintilla.dll in the directory above scintillacon.py, but it
came with pywin32, so it *should* be the correct one.
DLL inspector says it's a 64-bit, which is correct for my os.

I copy that dll, and indeed, all binaries in that directory (just to be
sure) into my program directory and it still does not work!

Try importing win32api in the same context. If that fails, check PATH
for pywintypesXY.dll:

 where pywintypes*.dll



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] playing with scintillacon

2017-12-15 Thread Kurt Eilander
Ok, I found scintilla.dll in the directory above scintillacon.py, but it 
came with pywin32, so it *should* be the correct one.

DLL inspector says it's a 64-bit, which is correct for my os.

I copy that dll, and indeed, all binaries in that directory (just to be 
sure) into my program directory and it still does not work!


Yet, the program Pythonwin.exe in that directory works fine and does its 
syntax highlighting with scintilla.dll.


I have no idea what could be wrong.  Oh!  To know what that little %1 means!


On 12/15/2017 10:23 AM, Jim Bell wrote:
"... not a valid Win32 application" sounds like a 32/64-bit issue to 
me. The 32/64-bit version of python you're running: does it match the 
DLLs?



On 2017-12-14 6:10 PM, Kurt Eilander wrote:

Hey all,

I recently noticed that pythonwin comes with a scintilla wrapper. 
Seems USEFUL!  so I decided to (scientifically) try poking it with a 
stick to see what it does.
(https://github.com/mhammond/pywin32/tree/7da19cd2ca3fac06638d9af690b8b6f5fcc65e8b/Pythonwin/pywin/scintilla) 



I didn't get too far, for when I do:
    from scintilla import scintillacon
I get:
    ImportError: DLL load failed: %1 is not a valid Win32 application.

Presumably this means there's a dll it can't find? Unfortunately the 
%1 is not replaced with what it's looking for.  (If there's not a bug 
out on this somewhere, there probably should be.) That's not the 
point though.  Point is: what are we looking for?


Thanks,
-Kurt






___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] playing with scintillacon

2017-12-14 Thread Kurt Eilander

Hey all,

I recently noticed that pythonwin comes with a scintilla wrapper. Seems 
USEFUL!  so I decided to (scientifically) try poking it with a stick to 
see what it does.

(https://github.com/mhammond/pywin32/tree/7da19cd2ca3fac06638d9af690b8b6f5fcc65e8b/Pythonwin/pywin/scintilla)

I didn't get too far, for when I do:
    from scintilla import scintillacon
I get:
    ImportError: DLL load failed: %1 is not a valid Win32 application.

Presumably this means there's a dll it can't find?  Unfortunately the %1 
is not replaced with what it's looking for.  (If there's not a bug out 
on this somewhere, there probably should be.) That's not the point 
though.  Point is: what are we looking for?


Thanks,
-Kurt

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] CreateDesktop() and displaying a window on it

2017-04-06 Thread Kurt Eilander

Hey all,

I'm trying to get system modal functionality like the UAC dialog.

According to http://developex.com/blog/system-modal-back/ the thing to 
do is to create and switch to a new desktop.


Therefore, I'm doing:

hDeskOld=win32service.GetThreadDesktop(win32api.GetCurrentThreadId())
hDesk=win32service.CreateDesktop("SysModalDesktop",0,win32con.GENERIC_ALL,None) 


hDesk.SwitchDesktop() # switch to the new desktop
try:
root=Tk()
app=SysmodalDialog(root,title,message,img)
app.mainloop()
except Exception,e:
print e
hDeskOld.SwitchDesktop() # switch back
hDesk.CloseDesktop() # done

The tk stuff inside the try works fine on its own.
If I replace the Tk stuff with time.sleep(5.0), then desktops switch 
fine as well.


The problem is I can't get the tk app to show on the new desktop (and 
therefore mainloop() blocks and I can't get back out of it!)


I tried changing Tk() to Tk(screenName="SysModalDesktop") but that 
didn't make a difference.


How do I make my window go to the right desktop??

-Kurt

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] win32api handle incompatible with ctypes?

2017-03-04 Thread Kurt Eilander

Hey all,

I'm having another problem.  I'm wanting to get the size of a dll 
resource, but...


When I do:
try:
hLib=win32api.GetModuleHandle(fileName)
except:
hLib=win32api.LoadLibrary(fileName)
if hLib==None:
raise WindowsError('File not found, '+fileName)
hResInfo=ctypes.windll.kernel32.FindResourceW(hLib,index,type)
size=ctypes.windll.kernel32.SizeofResource(hLib,hResInfo)

It throws:
hResInfo=ctypes.windll.kernel32.FindResourceW(hLib,index,type)
ctypes.ArgumentError: argument 1: 'exceptions.OverflowError'>: long int too long to convert


Almost like ctypes doesn't like the win32api handle.

My machine is 64 bit.  Is that what ctypes is not liking?  Is there a 
way around it?


-Kurt
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] What does pythoncom interface look like?

2017-01-08 Thread Kurt Eilander

Hey all,

I'm trying to create a win32com server that implements a standard 
interface (IExtractImage)


I've added the iid to _com_interfaces_ and the method names to 
_public_methods_, but now I'm at a complete loss how to implement them.


For instance, given the method,

HRESULT IExtractImage::GetLocation(
  [out]   LPWSTR pszPathBuffer,
  [in]DWORD  cchMax,
  [out]   DWORD  *pdwPriority,
  [in]const  SIZE   *prgSize,
  [in]DWORD  dwRecClrDepth,
  [in, out]   DWORD  *pdwFlags
);

How in the world is that supposed to look as a python method??

(Or is there some c++ or other glue I'd need to write to define that?)


Thanks,
-K

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] shell_view.py folder not browsable

2016-07-06 Thread Kurt Eilander

Hey all,

I was hoping to create my own IShellFolder in python, but there seems to
be something wrong with the example on my system.
(Win7 64bit, Python 2.7)

The folder shows up on the desktop, but I cannot open it.  I saw an
earlier thread where the solution was to right-click and select
'explore', but that doesn't even work for me.  The context menu only has
Cut, Create Shortcut, and Delete.

Not seeing any errors in the syslogs.

Any fixes or suggestions would be most appreciated!

Thanks in advance,
-Kurt


Today I decided to try it on Vista 32-bit, SP2.  Also, this was pristine 
code right off the Anaconda bundle.


This time when I right-click, open on "Python Path Shell Browser" I see 
a brief blip, like it wanted to draw the window frame but decided not 
to.  This was the only visible difference (and I think even that could 
be accounted for by the slower speed of the machine).


Again, I run mmc and look at the syslogs.  Nothing.

That's a pretty old system.  Just curious, when was the last time 
anybody has tried this example?  Its starting to feel like the 
non-workingness may have been around for a long time.


-Kurt

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] shell_view.py folder not browsable

2016-06-23 Thread Kurt Eilander

Hey all,

I was hoping to create my own IShellFolder in python, but there seems to 
be something wrong with the example on my system.

(Win7 64bit, Python 2.7)

The folder shows up on the desktop, but I cannot open it.  I saw an 
earlier thread where the solution was to right-click and select 
'explore', but that doesn't even work for me.  The context menu only has 
Cut, Create Shortcut, and Delete.


Not seeing any errors in the syslogs.

Any fixes or suggestions would be most appreciated!

Thanks in advance,
-Kurt
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously

2012-07-17 Thread Kurt Munson
I have been using pywin32 successfully for years to control Excel.  Now, 
suddenly I get errors executing the same code that has run previously.

My python code controls Excel like this:


import win32com.client
xl = win32com.client.DispatchEx(Excel.Application)
xl.DisplayAlerts = 0
xl.visible = 0


The last line('xl.visible = 0') now causes an error:


type 'exceptions.AttributeError''win32com.gen_py.Microsoft Excel 14.0 Object 
Library._Application instance at 0x425283464' object has no attribute 
'visible' [Function: glyphscript Line:63 | Function: __setattr__ Line:470]


This error goes away if I use xl.Visible instead of xl.visible - notice the 
uppercase V.  But then I get all sorts of other errors, in places that didn't 
error previously.

Why would this code have worked for years, and then suddenly not work now?

I am using Python 2.6.5 and pywin32-214 on 64 bit Windows 7.  I uninstalled and 
reinstalled Python and pywin32, but the new errors persist.

-Kurt



Confidentiality Notice: This email may contain confidential and/or privileged 
information. If you are not the intended recipient of this message, please 
delete it immediately and inform the sender that you have received this message 
in error.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously

2012-07-17 Thread Kurt Munson
Dunno exactly what you mean by what's your Dispatch code look like.

If you mean what am I doing with Excel via Python, it's like this:  it creates 
an Excel spreadsheet, adds a bunch of content, formats cells, etc.  All of this 
worked beautifully until this morning.

Here is a little bit of the code I am using to control Excel:

code
import win32com.client
xl = win32com.client.DispatchEx(Excel.Application)

# other stuff

xl.DisplayAlerts = 0
xl.Visible = 0

# more other stuff

currentSheet.Range(A1:B1).EntireColumn.AutoFit

# more more other stuff

plotbutton = currentSheet.buttons.Add(300, 8, 80, 45)
/code

Incidentally, I tried changing the dispatch line to use dynamic dispatch using 
this code:

code
xl = win32com.client.dynamic.Dispatch(Excel.Application)
/code

...and I still run into apparent case sensitivity, like not recognizing 
xl.visible, in lower case.  I thought dynamic dispatch would remove case 
sensitivity.

-Kurt


-Original Message-
From: Tim Golden [mailto:m...@timgolden.me.uk]
Sent: Tuesday, July 17, 2012 10:27 AM
To: Kurt Munson; python-win32@python.org
Subject: Re: [python-win32] new Pywin32 errors stating 'object has no 
attribute' - and the code worked previously

[cc-ing the list back in so you get the benefit of more and greater 
intelligences...]


On 17/07/2012 15:20, Kurt Munson wrote:
 I don't get it: I haven't made any changes to that Dispatch call in
 months!

 My code worked for months with the existing Dispatch method, up
 through yesterday afternoon, then began returning errors this morning.
 How could this be?


Well maybe I'm wrong. Someone else might have a better idea, but it's a classic 
symptom of this issue. What does your Dispatch code look like?

TJG

Confidentiality Notice: This email may contain confidential and/or privileged 
information. If you are not the intended recipient of this message, please 
delete it immediately and inform the sender that you have received this message 
in error.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously

2012-07-17 Thread Kurt Munson
There almost nothing in C:\Python26\Lib\site-packages\win32com\gen_py.

In a subfolder \00020813---C000-0046x0x1x7, I have 30 .py and 
.pyc, all generated in the last day.

Are you saying that they should be removed?

-Kurt


-Original Message-
From: python-win32-bounces+kurt.munson=hbmncode@python.org 
[mailto:python-win32-bounces+kurt.munson=hbmncode@python.org] On Behalf Of 
Graham Bloice
Sent: Tuesday, July 17, 2012 11:31 AM
To: python-win32@python.org
Subject: Re: [python-win32] new Pywin32 errors stating 'object has no 
attribute' - and the code worked previously

 -Original Message-
 Subject: Re: [python-win32] new Pywin32 errors stating 'object has no
 attribute' - and the code worked previously

 On 17/07/2012 16:05, Kurt Munson wrote:
  Dunno exactly what you mean by what's your Dispatch code look like.

 Well pretty much what you posted, in fact :)

  Incidentally, I tried changing the dispatch line to use dynamic
  dispatch using this code:
 
  code xl = win32com.client.dynamic.Dispatch(Excel.Application)
  /code
 
  ...and I still run into apparent case sensitivity, like not
  recognizing xl.visible, in lower case.  I thought dynamic dispatch
  would remove case sensitivity.

 So did I:

 dump
 ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python 2.7.1
 (r271:86832, Feb  7 2011, 11:30:38) [MSC v.1500 32 Type help,
copyright,
 credits or license for more infor
  import win32com.client
  xl = win32com.client.dynamic.Dispatch(Excel.Application)
  xl.visible
 False
  xl.Visible
 False
 
 

 /dump

 whereas:

 dump
  xl2 = win32com.client.gencache.EnsureDispatch(Excel.Application)
  xl2.visible
 Traceback (most recent call last):
   File stdin, line 1, in module
   File c:\python27\lib\site-packages\win32com\client\__init__.py,
 line
462,
 in __getattr__
 raise AttributeError('%s' object has no attribute '%s' %
(repr(self), attr))
 AttributeError: 'win32com.gen_py.Microsoft Excel 11.0 Object
 Library._Application instance at 0x58072680' object has no attribute
'visible'
 
 /dump


 Well I'm stumped. Hopefully someone more knowledgeable can chip in.

[Graham Bloice said]

Maybe remove the generated early binding .py for Excel in win32com\gen_py 
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Confidentiality Notice: This email may contain confidential and/or privileged 
information. If you are not the intended recipient of this message, please 
delete it immediately and inform the sender that you have received this message 
in error.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously

2012-07-17 Thread Kurt Munson
Graham,

Thanks for the suggestion - deleting the \win32com\gen_py .py and .pyc files 
solved the problem!

It appears that my dispatch (whether static or dynamic) was using old generated 
py instead of regenerating.  Why would this be?

Either way, deleting the folder under \win32com\gen_py solved this problem.  
Thanks again for the help.

-Kurt


-Original Message-
From: python-win32-bounces+kurt.munson=hbmncode@python.org 
[mailto:python-win32-bounces+kurt.munson=hbmncode@python.org] On Behalf Of 
Graham Bloice
Sent: Tuesday, July 17, 2012 11:56 AM
To: python-win32@python.org
Subject: Re: [python-win32] new Pywin32 errors stating 'object has no 
attribute' - and the code worked previously

 -Original Message-
 From: Kurt Munson [mailto:kurt.mun...@hbmncode.com]
 Sent: 17 July 2012 16:46
 To: Graham Bloice; python-win32@python.org
 Subject: RE: [python-win32] new Pywin32 errors stating 'object has no 
 attribute' - and the code worked previously

 There almost nothing in C:\Python26\Lib\site-packages\win32com\gen_py.

 In a subfolder \00020813---C000-0046x0x1x7, I have 30
.py
 and .pyc, all generated in the last day.

 Are you saying that they should be removed?


[Graham Bloice said]

Have a quick look at them and if they are all for Excel interfaces, yes.
I have a vague recollection that even dynamic dispatch will use the generated 
files if present.


 -Original Message-
 From: python-win32-bounces+kurt.munson=hbmncode@python.org
 [mailto:python-win32-bounces+kurt.munson=hbmncode@python.org]
 On Behalf Of Graham Bloice
 Sent: Tuesday, July 17, 2012 11:31 AM
 To: python-win32@python.org
 Subject: Re: [python-win32] new Pywin32 errors stating 'object has no 
 attribute' - and the code worked previously

  -Original Message-
  Subject: Re: [python-win32] new Pywin32 errors stating 'object has 
  no attribute' - and the code worked previously
 
  On 17/07/2012 16:05, Kurt Munson wrote:
   Dunno exactly what you mean by what's your Dispatch code look
like.
 
  Well pretty much what you posted, in fact :)
 
   Incidentally, I tried changing the dispatch line to use dynamic 
   dispatch using this code:
  
   code xl = win32com.client.dynamic.Dispatch(Excel.Application)
   /code
  
   ...and I still run into apparent case sensitivity, like not 
   recognizing xl.visible, in lower case.  I thought dynamic dispatch 
   would remove case sensitivity.
 
  So did I:
 
  dump
  ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python 
  2.7.1 (r271:86832, Feb  7 2011, 11:30:38) [MSC v.1500 32 Type 
  help,
 copyright,
  credits or license for more infor
   import win32com.client
   xl = win32com.client.dynamic.Dispatch(Excel.Application)
   xl.visible
  False
   xl.Visible
  False
  
  
 
  /dump
 
  whereas:
 
  dump
   xl2 = 
   win32com.client.gencache.EnsureDispatch(Excel.Application)
   xl2.visible
  Traceback (most recent call last):
File stdin, line 1, in module
File c:\python27\lib\site-packages\win32com\client\__init__.py,
  line
 462,
  in __getattr__
  raise AttributeError('%s' object has no attribute '%s' %
 (repr(self), attr))
  AttributeError: 'win32com.gen_py.Microsoft Excel 11.0 Object 
  Library._Application instance at 0x58072680' object has no 
  attribute
 'visible'
  
  /dump
 
 
  Well I'm stumped. Hopefully someone more knowledgeable can chip in.
 
 [Graham Bloice said]

 Maybe remove the generated early binding .py for Excel in 
 win32com\gen_py ___
 python-win32 mailing list
 python-win32@python.org
 http://mail.python.org/mailman/listinfo/python-win32

 Confidentiality Notice: This email may contain confidential and/or
privileged
 information. If you are not the intended recipient of this message,
please
 delete it immediately and inform the sender that you have received 
 this message in error.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously

2012-07-17 Thread Kurt Munson
Point taken, while trying to avoid a discussion on the validity of case 
sensitivity. 8)

-Kurt


-Original Message-
From: python-win32-bounces+kurt.munson=hbmncode@python.org 
[mailto:python-win32-bounces+kurt.munson=hbmncode@python.org] On Behalf Of 
Tim Roberts
Sent: Tuesday, July 17, 2012 12:31 PM
To: Python-Win32 List
Subject: Re: [python-win32] new Pywin32 errors stating 'object has no 
attribute' - and the code worked previously

Kurt Munson wrote:
 Thanks for the suggestion - deleting the \win32com\gen_py .py and .pyc files 
 solved the problem!

No, not really.  What you did was HIDE the problem.  The PROBLEM is that you 
are simply using the wrong name for that property.  The property name is 
Visible with a capital V, and it always has been.  You have been relying on 
the case-insensitivity that dynamic dispatch provides.
In my opinion, that's a dangerous practice, and your experience here shows why.

--
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Confidentiality Notice: This email may contain confidential and/or privileged 
information. If you are not the intended recipient of this message, please 
delete it immediately and inform the sender that you have received this message 
in error.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] pywin32 install error?

2009-10-24 Thread Kurt Schwarz
Hello,

I attempted to install pywin32 build 214 for Python 3.1.1 and I recieve this
trackback after the install completes:

Traceback (most recent call last):
  File string, line 601, in module
  File string, line 329, in install
  File string, line 15, in write
AttributeError: 'NoneType' object has no attribute 'write'

If I try to import a pywin32 module I get this ImportError:

import win32gui
ImportError: DLL load failed: The specified module could not be found.

Anyone know how to correct this?
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Controlling Excel via COM: errors with conditional formatting

2008-09-24 Thread kurt munson

I  have written a Python program to control MS Excel via win32com.client. This 
allows me to create and control an Excel spreadsheet.I want to use Excel's 
conditional formatting to color certain cells, but I can't get it to 
work.Here's the code I use:
 

import win32com.clientxl= 
win32com.client.Dispatch(Excel.Application)channamesSheet.Cells(6,3).FormatConditions.Add()
 Type:=1, Operator:=4, 
Formula1:==C5channamesSheet.Cells(6,3).FormatConditions(1).Interior.ColorIndex
 = 3I got this code from a record and replay macro in Excel, then swapped out 
the xl constants for numeric values (1 and 4).This gives me a syntax error when 
running.I have tried both .Add and .Add(), since sometimes these () are 
necessary.What am I doing wrong?
_
Get more out of the Web. Learn 10 hidden secrets of Windows Live.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32