Hi all,
I'm a Python beginner and trying to run the codes from Chapter 5 of Python pramming on win32. But when I tested the COM object with VBA, I got an error msg saying runtime error 438. Is there anyone can help me out? Thanks in advance!
Here are the codes:
[Python]
class PythonUtilities:
_public_methods_ = [ 'SplitString' ]
_reg_progid_ = "PythonDemos.Utilities"
_reg_clsid_ = "{D81903FB-62F2-4FB1-993E-63CAF4C963A0}"
def SplitString(self, val, item=None):
import string
if item != Nome: item = str(item)
return string.split(str(val), item)
if __name__=='__main__':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtil ities)
After running above scripts, the PythonWin interactive window displayed
Registering COM server...
Registered: PythonDemos.Utilities
[VBA]
Sub TestPython()
Set PythonUtils = CreateObject("PythonDemos.Utilities")
response = PythonUtils.SplitString("Hello from VB")
For Each Item In response
MsgBox Item
Next
End Sub
The code stopped at "response = PythonUtils.SplitString("Hello from VB")".
|