import platform
platform.architecture() #('64bit', 'WindowsPE')
I'm running on 64 bit, specifically:
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit
(AMD64)] :: Anaconda, Inc. on win32`
I created a COM server which I'd like to call from a 64 bit client:
class HelloWorld:
# pythoncom.CreateGuid()
_reg_clsid_ = "{E32B2663-BD8C-472A-AC96-142AE4665FD7}"
_reg_desc_ = "MyLib COM server"
_reg_progid_ = "MyLib.HelloWorld"
_public_methods_ = ["Hello"]
_public_attrs_ = ["softspace", "noCalls"]
_readonly_attrs_ = ["noCalls"]
def __init__(self):
self.softspace = 1
self.noCalls = 0
def Hello(self, who):
self.noCalls = self.noCalls + 1
# insert "softspace" number of spaces
return "Hello" + " " * self.softspace + str(who)
if __name__ == '__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(HelloWorld)
Registered using: python server.py - (call the __main__ method to register the server)
From a 64 bit COM client (Excel VBA), I am unable to create an instance
Sub t()
Dim a As Object
Set a = CreateObject("MyLib.HelloWorld")
End Sub
I get
Module not found
I can in python 64 bit
from comtypes.client import CreateObject
c = CreateObject('MyLib.HelloWorld')
I can in a 32 bit VBA host.
I'm guessing my python server is being declared 32 bit, python comtypes just worksTM regardless of server bitness.