Re: [python-win32] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Dan Moisan
You all are brilliant for responding. Thank you for being so kind! I will
try these fixes and get back to you. Thank you so much!!!

On Wed, Dec 8, 2021 at 4:32 PM Mark Hammond 
wrote:

> Another possibility for the failure is the environment office is running
> under (which broadly speaking can be described as the PATH).
>
> Back in the day, it was very common for Python and pywin32 to end up
> sticking stuff in the system32 directory, then things like COM would
> work in almost every context, as the system directory was (almost)
> always on the path.
>
> However, these days that's far less likely to be true - so the problem
> might be as simple as the fact that pythonXX.dll and pythoncomXX.dll
> can't be located when office is running, although can be in your pycharm
> environment.
>
> Ensuring the directory with these files is on the PATH for office is the
> generic advice, but it's difficult to give more specific advice without
> knowing more about your specific environment.
>
> Cheers,
>
> Mark
>
> On 8/12/2021 1:49 pm, Dan Moisan wrote:
> > I apologize in advance for the basic question, but I have spent about 40
> > hours researching how to make the demo "outlookAddin.py" load on my
> > Outlook 2016 32 bit application. I am running Python version 3.7 and I
> > can successfully run the outlookAddin.py script from PyCharm. But then
> > when I open outlook, I always receive the message "... not loaded. a
> > runtime error occurred during the loading of the com add-in".
> >
> > I am sure that I missing a very basic step to make this run, but I can't
> > seem to find anything online. Do I need to do something to compile the
> > outlookAddin.py script before or after I run it? Or should the add-in
> > load after it is registered? I'm so sorry for such a basic question.
> >
> > Thank you!
> >
> > Dan
> >
> > ___
> > python-win32 mailing list
> > python-win32@python.org
> > https://mail.python.org/mailman/listinfo/python-win32
>
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Mark Hammond
Another possibility for the failure is the environment office is running 
under (which broadly speaking can be described as the PATH).


Back in the day, it was very common for Python and pywin32 to end up 
sticking stuff in the system32 directory, then things like COM would 
work in almost every context, as the system directory was (almost) 
always on the path.


However, these days that's far less likely to be true - so the problem 
might be as simple as the fact that pythonXX.dll and pythoncomXX.dll 
can't be located when office is running, although can be in your pycharm 
environment.


Ensuring the directory with these files is on the PATH for office is the 
generic advice, but it's difficult to give more specific advice without 
knowing more about your specific environment.


Cheers,

Mark

On 8/12/2021 1:49 pm, Dan Moisan wrote:
I apologize in advance for the basic question, but I have spent about 40 
hours researching how to make the demo "outlookAddin.py" load on my 
Outlook 2016 32 bit application. I am running Python version 3.7 and I 
can successfully run the outlookAddin.py script from PyCharm. But then 
when I open outlook, I always receive the message "... not loaded. a 
runtime error occurred during the loading of the com add-in".


I am sure that I missing a very basic step to make this run, but I can't 
seem to find anything online. Do I need to do something to compile the 
outlookAddin.py script before or after I run it? Or should the add-in 
load after it is registered? I'm so sorry for such a basic question.


Thank you!

Dan

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


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


Re: [python-win32] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Vernon D. Cole
Thanks, Tim.

Your depth of knowledge is appreciated.
I have never understood the "magic" which happens when you make a COM call.
Now it all makes sense why 32 and 64 bit COM are mutually incompatible.


On Wed, Dec 8, 2021 at 1:52 PM Tim Roberts  wrote:

> 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
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Steven Manross
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 
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---C000-0046}
{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  On 
Behalf Of Tim Roberts
Sent: Wednesday, December 08, 2021 1:43 PM
To: python-win32 
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


Re: [python-win32] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Tim Roberts

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.



smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Vernon D. Cole
Most likely, you are running a 64  bit version of Python.
Due to Windows restrictions, only 32 bit programs can talk to each other.
If you download and install a 32 bit version of Python, you may find
success.
PyCharm and Windows will happily allow multiple versions of Python to work
alongside each other.
Select your Python version under File --> Settings --> Project --> Python
Interpreter


On Tue, Dec 7, 2021 at 8:30 PM Dan Moisan  wrote:

> I apologize in advance for the basic question, but I have spent about 40
> hours researching how to make the demo "outlookAddin.py" load on my Outlook
> 2016 32 bit application. I am running Python version 3.7 and I can
> successfully run the outlookAddin.py script from PyCharm. But then when I
> open outlook, I always receive the message "... not loaded. a runtime error
> occurred during the loading of the com add-in".
>
> I am sure that I missing a very basic step to make this run, but I can't
> seem to find anything online. Do I need to do something to compile the
> outlookAddin.py script before or after I run it? Or should the add-in load
> after it is registered? I'm so sorry for such a basic question.
>
> Thank you!
>
> Dan
> ___
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32