Hi all,<br>I&#39;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,&nbsp; I got an error msg saying runtime error 438. Is there anyone can help me out? Thanks in advance!<br>
<br>Here are the codes:<br>[Python]<br><span style="font-family: courier new,monospace;">class PythonUtilities:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; _public_methods_ = [ &#39;SplitString&#39; ]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; _reg_progid_ = &quot;PythonDemos.Utilities&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; _reg_clsid_ = &quot;{D81903FB-62F2-4FB1-993E-63CAF4C963A0}&quot;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">def SplitString(self, val, item=None):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; import string</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; if item != Nome: item = str(item)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; return string.split(str(val), item) </span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">if __name__==&#39;__main__&#39;:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Registering COM server...&quot;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; import win32com.server.register</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; win32com.server.register.UseCommandLine(PythonUtilities)<br>
<br></span>After running above scripts,&nbsp; the PythonWin interactive window displayed<br><span style="font-family: courier new,monospace;">Registering COM server...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Registered: PythonDemos.Utilities </span><br>
<br>[VBA]<br><span style="font-family: courier new,monospace;">Sub TestPython()</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Set PythonUtils = CreateObject(&quot;PythonDemos.Utilities&quot;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">response = PythonUtils.SplitString(&quot;Hello from VB&quot;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">For Each Item In response</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; MsgBox Item</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Next</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">End Sub</span><br>
<br>The code stopped at &quot;<span style="font-family: courier new,monospace;">response = PythonUtils.SplitString(&quot;Hello from VB&quot;)</span>&quot;.<br clear="all"><span style="font-family: courier new,monospace;"></span><br>
-- <br>Love. Peace. Music.