[python-win32] A problem on testing COM object with VBA

Tim Roberts timr at probo.com
Fri Apr 4 18:33:20 CEST 2008


Xue Shan wrote:
> 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)

The problem here is that "None" is misspelled inside SplitString.  This 
won't be noticed until SplitString is actually executed.

By the way, since Python 2.x, you don't need to "import string" any 
more.  You can write that as:

def SplitString( self, val, item=None ):
    if item: item = str(item)
    return str(val).split( item )

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list