Kelie wrote: > Hello group, > > Following the example in Mark's book, I tried creating a simple COM server > exposing two methods from the re module. But could not get it to work. Here is > the code: > > class PythonModule_re: > _public_methods_ = ['pyfindall', 'pysplit'] > _reg_progid_ = "PythonModule.re" > # NEVER copy the following ID > # Use "print pythoncom.CreateGuid()" to make a new one. > _reg_clsid_ = "{770E12AD-FED0-47C1-8457-E737FE6F5843}" > > def pyfindall(self, pat, s): > import re > return re.findall(re.compile(pat), s) > > def pysplit(self, pat, s): > import re > return re.split(re.compile(pat), s) > > if __name__=='__main__': > print "Registering COM server..." > import win32com.server.register > win32com.server.register.UseCommandLine(PythonModule_re) > > This is the vba code to test the COM server from which I got an error saying > "Objects doesn't support this property or method." > > Public Sub Test() > Dim pyRegex As Object > Dim r1 As Variant > Dim r2 As Variant > > Set pyRegex = CreateObject("PythonModule.re") > r1 = pyRegex.pyfindall("\d", "a1b2c3") > r2 = pyRegex.pysplit("\d", "a1b2c3") > Debug.Print "Done." > End Sub > > The odd thing (to me) was if I rename the function pyfindall to findall, it > works. But I could not do that with pysplit because there is a vb function > called Split. > > Any hints? Thanks a lot! > > - kelie
I made the following small changes (but only to the VB program) and it runs without any errors for me: Public Sub Test() Dim pyRegex As Object Dim r1 As Variant Dim r2 As Variant MsgBox "entering test" Set pyRegex = CreateObject("PythonModule.re") MsgBox "Created instance of pyRegex" MsgBox "Calling pyfindall" r1 = pyRegex.pyfindall("\d", "a1b2c3") MsgBox "Calling pysplit" r2 = pyRegex.pysplit("\d", "a1b2c3") MsgBox "Done." End Sub -Larry _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32