win32com: error 80004005

A

ago

I am trying to make the win32com HelloWorld server work with a VBA
client but I get:

Run-time error '-2147467259(80004005)':
Automation error
Unspecified error

I googled for the error but the suggested solutions (commenting out
_reg_class_spec_ and putting the server on the python path) do not seem
to make any difference (to be precise, unless I comment out
_reg_class_spec_ I cannot register the server at all) . The server
works under the python client but not on excel vba. I also tried to
debug with win32traceutil.py but I can only see the trace when using
the python client, not with excel. Any hint would be appreciated.

### PYTHON SERVER ###
class HelloClass:
_reg_desc_ = "Python Test COM Server"
_reg_clsid_ = "{91281AFC-25DF-4400-8868-FDBFCA2612A2}"
_reg_progid_ = "Python.HelloHello"
_public_methods_ = ['Hello']

def __init__(self): pass
def Hello(self): return "Hello"

if __name__ == "__main__":
import win32com.server.register
import sys
#sys.argv.append("--debug")
win32com.server.register.UseCommandLine(HelloClass)

### PYTHON CLIENT (WORKS) ###
import win32com.client
obj = win32com.client.Dispatch('Python.HelloHello')
print obj.Hello()

### VBA CLIENT (ERROR 80004005 WHEN EXECUTING "CreateObject") ###
Public Sub test()
Dim obj As Object
Set obj = CreateObject("Python.HelloHello")
MsgBox obj.Hello("ago")
End Sub
 
A

ago

I solved it. If someone else is in the same situation...

It was due to a defective installation. I reinstalled python and pywin,
re-registered the server and everything worked well.
 
R

Roger Upole

The only thing I see wrong is that the Hello method
doesn't take any arguments, but the VB code is passing one.
It works fine for me if I remove the arg.
When registered with --debug, you should still be able
to see the output in Pythonwin's trace collector window
even when the object is instantiated via VB.

hth
Roger

ago said:
I am trying to make the win32com HelloWorld server work with a VBA
client but I get:

Run-time error '-2147467259(80004005)':
Automation error
Unspecified error

I googled for the error but the suggested solutions (commenting out
_reg_class_spec_ and putting the server on the python path) do not seem
to make any difference (to be precise, unless I comment out
_reg_class_spec_ I cannot register the server at all) . The server
works under the python client but not on excel vba. I also tried to
debug with win32traceutil.py but I can only see the trace when using
the python client, not with excel. Any hint would be appreciated.

### PYTHON SERVER ###
class HelloClass:
_reg_desc_ = "Python Test COM Server"
_reg_clsid_ = "{91281AFC-25DF-4400-8868-FDBFCA2612A2}"
_reg_progid_ = "Python.HelloHello"
_public_methods_ = ['Hello']

def __init__(self): pass
def Hello(self): return "Hello"

if __name__ == "__main__":
import win32com.server.register
import sys
#sys.argv.append("--debug")
win32com.server.register.UseCommandLine(HelloClass)

### PYTHON CLIENT (WORKS) ###
import win32com.client
obj = win32com.client.Dispatch('Python.HelloHello')
print obj.Hello()

### VBA CLIENT (ERROR 80004005 WHEN EXECUTING "CreateObject") ###
Public Sub test()
Dim obj As Object
Set obj = CreateObject("Python.HelloHello")
MsgBox obj.Hello("ago")
End Sub
 

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,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top