[python-win32] A problem on testing COM object with VBA
Tim Roberts
timr at probo.com
Fri Apr 4 19:02:25 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)
>
> if __name__=='__main__':
> print "Registering COM server..."
> import win32com.server.register
> win32com.server.register.UseCommandLine(PythonUtilities)
Ack, I just noticed your indentation. That's why you are getting the
438 error.
SplitString is at the same level as PythonUtilities here. That means
that SplitString is a global function -- it is not a member of the
PythonUtilities class. There is no SplitString member function, which
is why you get error 438: "object doesn't support this property or method".
You need to indent the SplitString function. Viz:
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: item = str(item)
return str(val).split( item)
if __name__=='__main__':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtilities)
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list