A problem on testing COM object with VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • applejump
    New Member
    • Apr 2008
    • 1

    A problem on testing COM object with VBA

    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.Ut ilities"
    _reg_clsid_ = "{D81903FB-62F2-4FB1-993E-63CAF4C963A0}"

    def SplitString(sel f, val, item=None):
    import string
    if item != Nome: item = str(item)
    return string.split(st r(val), item)

    if __name__=='__ma in__':
    print "Registerin g COM server..."
    import win32com.server .register
    win32com.server .register.UseCo mmandLine(Pytho nUtilities)

    After running above scripts, the PythonWin interactive window displayed
    Registering COM server...
    Registered: PythonDemos.Uti lities

    [VBA]
    Sub TestPython()

    Set PythonUtils = CreateObject("P ythonDemos.Util ities")
    response = PythonUtils.Spl itString("Hello from VB")
    For Each Item In response
    MsgBox Item
    Next

    End Sub

    The code stopped at "response = PythonUtils.Spl itString("Hello from VB")".
Working...