Win32com, and Excel issues.

A

Ant

Hi all,

I'm doing some Excel automation work for a friend, and am developing
on a machine running Office 2000. My friends machine is running Excel
2003. The code I've written works like a charm on my machine (in fact
all three of my machines), but falls over early on on Excel 2003.

The code snippet it falls over on is code to copy one worksheet after
another:

app = wincl.Dispatch("Excel.Application")
app.Visible = True
app.Workbooks.Open(self.filename)
sheet = app.Worksheets(1)
sheet.Copy(None, sheet)

and this last line throws the following exception:

pywintypes.com_error: (-2147417851, 'the server threw an exception.'
, None, None)

which isn't too helpful.

I'm wondering if something has changed in the Excel API that doesn't
allow a null parameter to Copy or some similar issue. I tried using
the keyword argument format, but that simply refused to work.

Other relevant information:

* The program is packaged using py2exe, so I know that the same
version of Python, and the same libraries are on each machine.
* One of the test machines running Excel 2000 does not have Python
installed.
* The machines are all of a similar spec.

Any ideas are welcome!
 
K

kyosohma

Hi all,

I'm doing some Excel automation work for a friend, and am developing
on a machine running Office 2000. My friends machine is running Excel
2003. The code I've written works like a charm on my machine (in fact
all three of my machines), but falls over early on on Excel 2003.

The code snippet it falls over on is code to copy one worksheet after
another:

app = wincl.Dispatch("Excel.Application")
app.Visible = True
app.Workbooks.Open(self.filename)
sheet = app.Worksheets(1)
sheet.Copy(None, sheet)

and this last line throws the following exception:

pywintypes.com_error: (-2147417851, 'the server threw an exception.'
, None, None)

which isn't too helpful.

I'm wondering if something has changed in the Excel API that doesn't
allow a null parameter to Copy or some similar issue. I tried using
the keyword argument format, but that simply refused to work.

Other relevant information:

* The program is packaged using py2exe, so I know that the same
version of Python, and the same libraries are on each machine.
* One of the test machines running Excel 2000 does not have Python
installed.
* The machines are all of a similar spec.

Any ideas are welcome!

I can't find anything about copying a worksheet, but I found a some
fairly detailed information about COM objects and getting more
information about Python's bindings to them here:
http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html or here:
http://mathieu.fenniak.net/plotting-in-excel-through-pythoncom/

Hopefully this will give you some pointers.

Mike
 
A

Ant

Hi Mike,
I can't find anything about copying a worksheet, but I found a some
fairly detailed information about COM objects and getting more
information about Python's bindings to them here:http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.htmlor here:http://mathieu.fenniak.net/plotting-in-excel-through-pythoncom/

Thanks, I've already seen those pages (in fact I have the book) but no
luck. In fact it's worse - I've tested it out on a different machine
running Excel 2003, and it works fine :-(

Which means that there's another variable at stake here...
 
K

kyosohma

Hi Mike,


Thanks, I've already seen those pages (in fact I have the book) but no
luck. In fact it's worse - I've tested it out on a different machine
running Excel 2003, and it works fine :-(

Which means that there's another variable at stake here...

Yeah. I have the book too. You might check to see if both PCs have the
Office SP2 on them. It shouldn't make a difference, but they shouldn't
change the way VBA behaves between versions either, and yet they do.
Sorry I wasn't of more help.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top