Terje Johan Abrahamsen
2002-05-22 22:32:01 UTC
I am writing a little porgram that pulls out some info from a cell in Excel.
It works great, excepy for when I try to pull out info from a spreadsheet
that I want info from. Here is the code:
import win32com.client
import win32com.client.dynamic
from win32com.client import Dispatch
import sys
class accountcurrents:
xlApp = Dispatch("Excel.Application")
#ex = Dispatch("Extra.System")
xlApp.Visible = 1
xlApp.Workbooks.Add()
xlBook = xlApp.Workbooks(1)
xlSheet = xlApp.Sheets(1)
xlrad = 2
xlpol = "Donald"
xlamount = 1.00
xldato = "1/11/11"
def __init__(self):
print"Hello"
def finnxlpolicy(self):
accountcurrents.xlrad = accountcurrents.xlrad + 1
accountcurrents.xlpol =
accountcurrents.xlSheet.Cells(accountcurrents.xlrad,1).Value
if accountcurrents.xlpol == None :
print "yes"
else:
pass
If I have a blank spreadsheet, and fill in some values in the A collumn, it
works great. However, when I use the spreadsheet that I actually want the
info from, it all crashes. The spreadsheet I want the info from looks like
this:
Policy# Effective Date Amount
MCK0259477 11/5/1998 240
MCK0278868 5/27/2001 -572.72
MCK0279107 1/14/2001 -1474.82
and so forth.
This errormessage comes:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Documents and Settings\dsporck\My
Documents\Python\accountcurrents\accountcurrents.py", line 23, in
finnxlpolicy
accountcurrents.xlpol =
accountcurrents.xlSheet.Cells(accountcurrents.xlrad,1).Value
File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line
347, in __getattr__
return apply(self._ApplyTypes_, args)
File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line
341, in _ApplyTypes_
return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid,
0, wFlags, retType, argTypes) + args), user, resultCLSID)
com_error: (-2146827864, 'OLE error 0x800a01a8', None, None)
I use win2k, and newest version of Python, PythonWin and Win32Com. I do not
change anything except for the contents of the spreadsheet. Even if I just
copy the info into the spreadsheet that normally works.
Thanks in advance,
Terje
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
It works great, excepy for when I try to pull out info from a spreadsheet
that I want info from. Here is the code:
import win32com.client
import win32com.client.dynamic
from win32com.client import Dispatch
import sys
class accountcurrents:
xlApp = Dispatch("Excel.Application")
#ex = Dispatch("Extra.System")
xlApp.Visible = 1
xlApp.Workbooks.Add()
xlBook = xlApp.Workbooks(1)
xlSheet = xlApp.Sheets(1)
xlrad = 2
xlpol = "Donald"
xlamount = 1.00
xldato = "1/11/11"
def __init__(self):
print"Hello"
def finnxlpolicy(self):
accountcurrents.xlrad = accountcurrents.xlrad + 1
accountcurrents.xlpol =
accountcurrents.xlSheet.Cells(accountcurrents.xlrad,1).Value
if accountcurrents.xlpol == None :
print "yes"
else:
pass
If I have a blank spreadsheet, and fill in some values in the A collumn, it
works great. However, when I use the spreadsheet that I actually want the
info from, it all crashes. The spreadsheet I want the info from looks like
this:
Policy# Effective Date Amount
MCK0259477 11/5/1998 240
MCK0278868 5/27/2001 -572.72
MCK0279107 1/14/2001 -1474.82
and so forth.
This errormessage comes:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Documents and Settings\dsporck\My
Documents\Python\accountcurrents\accountcurrents.py", line 23, in
finnxlpolicy
accountcurrents.xlpol =
accountcurrents.xlSheet.Cells(accountcurrents.xlrad,1).Value
File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line
347, in __getattr__
return apply(self._ApplyTypes_, args)
File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line
341, in _ApplyTypes_
return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid,
0, wFlags, retType, argTypes) + args), user, resultCLSID)
com_error: (-2146827864, 'OLE error 0x800a01a8', None, None)
I use win2k, and newest version of Python, PythonWin and Win32Com. I do not
change anything except for the contents of the spreadsheet. Even if I just
copy the info into the spreadsheet that normally works.
Thanks in advance,
Terje
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com