By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,309 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,309 IT Pros & Developers. It's quick & easy.

win32 com problem

P: n/a
I've got a slight problem when running an excel macro from python using
the win32.com.client module, in that it says it can't load the DLL file
(it doesn't say which one)

and gives me the following error message

Traceback (most recent call last):
File "<string>", line 93, in ?
File "<COMObject <unknown>>", line 14, in Run
File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line
258, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType,
argTypes) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
'Microsoft Office Excel', "The macro 'CTP.xla!sheet1.CTP' cannot be
found.", 'C:\\Program Files\\Microsoft
Office\\OFFICE11\\1033\\xlmain11.chm', 0, -2146827284), None)
Anybody have any ideas what this means?

Dec 5 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Mike P wrote:
I've got a slight problem when running an excel macro from python using
the win32.com.client module, in that it says it can't load the DLL file
Does it? All I see is a message that it can't find a macro.
(it doesn't say which one)
What happens when you run the macro from the Excel UI?

Have you tried using makepy?
>
and gives me the following error message

Traceback (most recent call last):
File "<string>", line 93, in ?
??? It might help if you showed us the code that you are executing.
File "<COMObject <unknown>>", line 14, in Run
File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line
258, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType,
argTypes) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
'Microsoft Office Excel', "The macro 'CTP.xla!sheet1.CTP' cannot be
found.", 'C:\\Program Files\\Microsoft
Office\\OFFICE11\\1033\\xlmain11.chm', 0, -2146827284), None)
Anybody have any ideas what this means?
Dec 5 '06 #2

P: n/a
Thanks for the quick reply,

the code i am running is the following

import win32com.client
xl = win32com.client.Dispatch("Excel.Application")
ppt = win32com.client.Dispatch("PowerPoint.Application")
ppt.Visible = 1 #open MS Powerpoint
xl.Visible = 1 #open MS Excel
xl.Workbooks.Open('%s/working_output.xls' % (working_dir))
xl.Workbooks.Open('Z:\\projects\\surveys\\SPSS - Generic
files\\CTP.xla')
ppt.Presentations.Open('Z:\\projects\\surveys\\SPS S - Generic
files\\Basic Template.ppt')
xl.Application.Workbooks("working_output").Activat e
xl.Application.Run("CTP.xla!sheet1.CTP")

I'm running via SPSS V15 which has a python plugin, i was previousky
running in V14 using the exact same code with no problems?

Thanks again

Mike

Dec 5 '06 #3

P: n/a

Mike P wrote:
Thanks for the quick reply,

the code i am running is the following

import win32com.client
xl = win32com.client.Dispatch("Excel.Application")
ppt = win32com.client.Dispatch("PowerPoint.Application")
ppt.Visible = 1 #open MS Powerpoint
xl.Visible = 1 #open MS Excel
xl.Workbooks.Open('%s/working_output.xls' % (working_dir))
xl.Workbooks.Open('Z:\\projects\\surveys\\SPSS - Generic
files\\CTP.xla')
Does this file contain a sheet named "sheet1"? Maybe it should be
"Sheet1"; I can never remember what is case-sensitive and what's not
:-)

If so, does that sheet contain a macro called "CTP"?
ppt.Presentations.Open('Z:\\projects\\surveys\\SPS S - Generic
files\\Basic Template.ppt')
xl.Application.Workbooks("working_output").Activat e
xl.Application.Run("CTP.xla!sheet1.CTP")
See above questions.
>
I'm running via SPSS V15 which has a python plugin, i was previousky
running in V14 using the exact same code with no problems?
Have you asked SPSS about the CTP.xla file (which I guess is supplied
by them)?

Don't expect so fast a response this time -- it's sleep time in this
timezone :-)

Cheers,
John

Dec 5 '06 #4

P: n/a
No Problem,

Thanks for your help so far, i've sent this problem off to SPSS as it
seems it doesn't work on a work colleagues machine either

Thanks for your time though

Mike

Dec 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.