I've used the Simple.py from page 213, because there is less involved.
when I run it- I see the registration messages. All is good so far.
I made one tiny change, related to the call to CreateGuid()
import pythoncom
class PythonCOMServer:
_public_methods_ = ['pyCOMSplit']
_reg_progid_= "PythonCOMDemo"
_reg_clsid_= pythoncom.CreateGuid()
def pyCOMSplit(StringFromVB):
from string import split
if self.StringFromVB != None:
return split(self.StringFromVB )
if __name__ == '__main__':
print"Registering COM server"
import win32com.server.register
win32com.server.register.UseCommandLine( PythonCOMServer )
When I try sending a string from the VB side,
Type Error; str() takes at most 1 arguments, two given
I see no explicit calls to str.
Here's the VB side
Option Explicit
Private Sub cmdToPython_Click()
Dim Python As Object
Dim FromPython As Variant
Set Python = CreateObject("PythonCOMDemo")
FromPython = Python.pyCOMSplit("This string to Python")
txtFromPython = FromPython
End Sub
This call, is what is causing the runtime exception
Python.pyCOMSplit ("This string to Python")
What am I doing wrong?
thanks
On 12/6/05, Mark Hammond <
[EMAIL PROTECTED]> wrote:
> >>Certainly COM would work. In this case your VB EXE would use
CreateObject
> >>to create a Python implemented object.
> As what type of Python Object?
> I have the VB6 ide open, and the references Browser as well,
> there is no generic Python object to include into a VB project.
> Which means one would have to create a Python COM server
> and Type library first, before being able to reference it
> from the VB IDE.
Actually, you don't need to create a typelib. Just register the PythonCOM
server, and have VB use CreateObject with the ProgID. All vars will need to
be declared as "object", and you wont get auto-complete type features, but
it will work. VB supports late-binding.
> Even though I have Python Programming in Win32, I'm not sure what
> needs to be done to make a minimal Python COM server that can be
> called from VB.
Pages 221 and 222 have an example using VBA (ie, the VB embedded in MSOffice
apps)
> Also, creating a type library requires using Visual C- which isn't a
> problem, it's the language of the IDL required to create the TLB that
> I don't udnerstand.
You should be able to avoid TLBs - certainly to get started...
Mark
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32