Hello all,
I'm having some trouble on the find function in Excel. A simple Find statement
works fine, but as soon as I want to use an advanced option (xlByColumns) I get
an error.
This is my program:
#!/usr/bin/python
from win32com.client import Dispatch
from win32com.client import constants
xlApp = Dispatch("Excel.Application")
xlApp.Visible = 1
xlApp.Workbooks.Open('c:\\temp\\python\\excel\\findtest.xls')
xlApp.Worksheets(1).Activate()
findcell = xlApp.ActiveSheet.UsedRange.Find('FXN3')
print findcell.Address
findcell =
xlApp.ActiveSheet.UsedRange.Find('FXN3',None,constants.xlValues,constants.xlWhole,constants.xlByColumns,constants.xlNext,False,False,None)
print findcell.Address
xlApp.Quit()
del xlApp
And this is the output:
C:\temp\python\excel>python findtest.py
$D$5
Traceback (most recent call last):
File "findtest.py", line 20, in ?
findcell = xlApp.ActiveSheet.UsedRange.Find('FXN3',None,constants.xlValues,c
onstants.xlWhole,constants.xlByColumns,constants.xlNext,False,False,None)
File "C:\Program Files\python24\lib\site-packages\win32com\gen_py\00020813-000
0-0000-C000-000000000046x0x1x4.py", line 21407, in Find
, MatchCase, MatchByte, SearchFormat)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
0, -2147352571), 9)
As you can see, the first find statement works fine, but the second returns an
error.
Any help on this would be much appreciated.
Thanks,
Patrick Asselman
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32