import pythoncom
class PythonUtilities:
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
_public_methods_ = ['SplitString']
_reg_progid_ ="PythonDemos.Utilities"
# NEVER copy the following ID
# Use "print pythoncom.CreateGuid()" to make a new one.
_reg_clsid_ ="{41E24E95-D45A-11D2-852C-204C4F4F5020}"
def SplitString(self, val,item=None):
import string
print(val)
# if item != None: item = str(item)
return val
# Add code so that when this script is run by
# Python.exe, it self-registers.
if __name__ =='__main__':
("Registering COM server")
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtilities)
以上为PYTON代码
下面为 按键精灵调用python实例
Dim ExcelSheet
Set ExcelSheet =CreateObject("PythonDemos.Utilities")
TracePrint ExcelSheet.SplitString("老K最棒")