Correct me if I am wrong...  but Office 2010+ comes in 64-bit and 32-bit 
versions.  I know that 2019 definitely does.

Providing he matches his Python architecture (32 or 64) to his Office 
application architecture (32 or 64), it should work unless that code has issues 
working in 64-bit mode?  I haven’t tried this myself in this particular case, 
as I've always installed 32-bit Office apps.  

As well, I just tried to run the addin code with my 64-bit python and it told 
me " Library not registered".  

C:\scripts>python outlookaddin.py
Traceback (most recent call last):
  File "outlookaddin.py", line 38, in <module>
    gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1, 
bForDemand=True) # Office 9
  File "C:\Python36\lib\site-packages\win32com\client\gencache.py", line 605, 
in EnsureModule
    bBuildHidden=bBuildHidden,
  File "C:\Python36\lib\site-packages\win32com\client\gencache.py", line 319, 
in MakeModuleForTypelib
    bBuildHidden=bBuildHidden,
  File "C:\Python36\lib\site-packages\win32com\client\makepy.py", line 257, in 
GenerateFromTypeLibSpec
    tlb = pythoncom.LoadRegTypeLib(typelibCLSID, major, minor, lcid)
pywintypes.com_error: (-2147319779, 'Library not registered.', None, None)

Its possible that my Office 2019 install doesn’t have the correct components or 
APPIDs or CLSIDs installed (even if I matched the python and office 
architectures) as I searched for them and couldn’t find them in the native x64 
and x86 registry subkeys:

* HKEY_CLASSES_ROOT
* HKLM\Software\Classes
* OR HKLM\Software\Wow6432Node\Classes

These 2 IDs  (Maybe only there in older office versions? Not Sure):
    {00062FFF-0000-0000-C000-000000000046}
    {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}

The Library Not registered is what I would expect if you were running into a 
64-bit python and 32-bit application (or vice versa) problem as the script just 
wouldn't find the needed library.  I see this a lot with ODBC access to MS SQL 
Server, Sybase, et al (not having the correct architecture's drivers installed 
to perform the operation I am expecting to work) in VBScript, Perl and Python.

HTH

Steven
-----Original Message-----
From: python-win32 <python-win32-bounces+steven=manross....@python.org> On 
Behalf Of Tim Roberts
Sent: Wednesday, December 08, 2021 1:43 PM
To: python-win32 <python-win32@python.org>
Subject: Re: [python-win32] Outlook Add-In Demo Question ... A runtime error 
occurred during the loading of the com add-in

Vernon D. Cole wrote:
> Most likely, you are running a 64  bit version of Python.
> Due to Windows restrictions, only 32 bit programs can talk to each other.

That comment demands clarification, because as stated it is quite misleading.

The issue here is that a 32-bit application can only load 32-bit DLLs. Outlook 
2016 is a 32-bit application, so when it as a COM client tries to load an 
in-process COM server (that is, his add-in), the COM server DLL must also be 
32-bit.

There are many, many ways that 32-bit and 64-bit programs can talk to each 
other.  This is a very specific instance.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to