Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Connecting to Python COM server from Excel VBA does not work

3 views
Skip to first unread message

diego

unread,
Dec 10, 2009, 4:50:09 AM12/10/09
to
I ran this script:
---------------------------
class Example(object):
_public_methods_ = ['Add','Mul']
_reg_progid_ = 'MyPython.Example'
_reg_clsid_ = '{E39ECD8C-7FAF-48B0-B914-1202319499D4}'

def Add(self,a,b): return a+b

def Mul(self,a,b): return a*b

if __name__ == '__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(Example)
---------------------------------
connecting to this COM server works with following VBS-script:
---------------------------------
Set ex = CreateObject("MyPython.Example")
msgbox ex.Add(1, 2)
---------------------------------

when i run following VBA script in excel
---------------------------------
Sub Testit()
Set ex = CreateObject("MyPython.Example")
MsgBox ex.Add(1, 2)
End Sub
---------------------------------

i get the error:
Run-time error '-2137024770 (8007007e)':
Automation error
The specified module could not be found

Any ideas what the problem could be?
Already searched a long time for solutions but did not find any....

thanks,
diego

Michel Claveau - MVP

unread,
Dec 10, 2009, 5:52:55 AM12/10/09
to
Hi !

Warning with lower/uppercases!
Try to make two versions of your methods (ex.: "add" & "ADD"), for study.

@+
--
MCI

diego

unread,
Dec 10, 2009, 7:26:03 AM12/10/09
to
On 10 Dez., 11:52, "Michel Claveau -


The error comes already at the first line of Excel/VBA code:


Set ex = CreateObject("MyPython.Example")


rgds,e

Message has been deleted

diego

unread,
Dec 10, 2009, 10:55:57 AM12/10/09
to
the problem was that i had never installed python on my workstation.
just had a Python25 folder with a batch-file that was adjustin the
PATH and executing %PYTHONHOME%python.exe
installed Python properly and now everything works fine....
0 new messages