[python-win32] chapter 5 : implementing com objects with python

Benjamin McNeill benjamin.f.mcneill at gmail.com
Mon Mar 25 22:51:08 EDT 2019


Hello,  I am trying to get this com server to work in VBA.  I can register
and deregister the server but I can not call it from vba.  Any
suggestions?  I am using windows 10 and office 365 with python3.7.

thanks!
--Ben

# SimpleCOMServer.py - A sample COM server - almost as small as they come!
#
# We simply expose a single method in a Python COM object.


class PythonUtilities:
    _public_methods_ = ['SplitString']
    _reg_progid_ = "PythonDemos.Utilities"

    # NEVER copy the following ID
    # Use "print(pythoncom.CreateGuid())" to make a new one.
    _reg_clsid_ = "{7D2089C4-CD6A-44BD-A6DC-CA3B3A8A8712}"

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


# Add code so that when this script is run by
# Python.exe, it self-registers.
if __name__ == '__main__':
    print("Registering COM server...")
    import win32com.server.register

    win32com.server.register.UseCommandLine(PythonUtilities)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20190325/74ce4694/attachment.html>


More information about the python-win32 mailing list