From christoph.dorner at gmx.de Sun Nov 14 08:02:32 2021 From: christoph.dorner at gmx.de (Christoph J. Dorner) Date: Sun, 14 Nov 2021 14:02:32 +0100 Subject: [python-win32] Issue with PythonCOM - Application.Run does not work for Access.Application In-Reply-To: References: Message-ID: All, I found in the archives an answer I could not find in my inbox. Thanks to Tim Roberts! So far Idid the instantiation via the database mdb-file and I did not do an EnsureDispatch call on the Access Application object. I tried this in my code and - voila - got an error that makepy could not read the library. I did a manual ensureDispatch for Access.Application from a Python console and got the following: Traceback (most recent call last): ? File "F:\WinPython\WPy64-3950\python-3.9.5.amd64\lib\site-packages\IPython\core\interactiveshell.py", line 3441, in run_code ??? exec(code_obj, self.user_global_ns, self.user_ns) ? File "", line 1, in ??? app = win32com.client.gencache.EnsureDispatch("Access.Application") ? File "F:\WinPython\WPy64-3950\python-3.9.5.amd64\lib\site-packages\win32com\client\gencache.py", line 531, in EnsureDispatch ??? mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) ? File "F:\WinPython\WPy64-3950\python-3.9.5.amd64\lib\site-packages\win32com\client\gencache.py", line 388, in EnsureModule ??? module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) ? File "F:\WinPython\WPy64-3950\python-3.9.5.amd64\lib\site-packages\win32com\client\gencache.py", line 263, in GetModuleForTypelib ??? AddModuleToCache(typelibCLSID, lcid, major, minor) ? File "F:\WinPython\WPy64-3950\python-3.9.5.amd64\lib\site-packages\win32com\client\gencache.py", line 559, in AddModuleToCache ??? SetTypelibForAllClsids(mod.CLSIDToClassMap) AttributeError: module 'win32com.gen_py.4AFFC9A0-5F99-101B-AF4E-00AA003F0F07x0x9x0' has no attribute 'CLSIDToClassMap' With Excel it works without error. I am wondering if this might be the issue Tim mentioned earlier regarding Python 64bit and Office / Acccess 32bit ? https://code.activestate.com/lists/python-win32/12574 Best regards Christoph Am 17.09.2021 um 09:26 schrieb Christoph J. Dorner: > Hi there, > > I need to call Office / VBA applications form a running Python script. > While calling VBA from Python using Application.Run works with EXCEL, > it does not work with ACCESS. What I do: > I link to the Office application via the win32com.client dispatch > mechanism as usual and I can see the application object in the Python > debugger. > If I do an excelapp.Run('xxx") everything is fine. > If I do an accessapp.Run('xxx") it throws an error -2147352562 which > win32api.FormatMessage states is an issue with the number of > parameters. But that cannot be the case as the UDF has no parameter > and I do not pass any (additional) parameter. > Moreover I simulated this accessapp.Run call from EXCEL in VBA and > there it works. > Moreover, I did a "passthrough" via EXCEL i. e. called a stub in EXCEL > VBA using excelapp.Run in Python which itself calls ACCESS VBA via > Application.Run as well. This works for ACCESS VBA code I cannot call > directly from Python. It even works to create/pass back VBA object > references from ACCESS via EXCEL to Python. > > I could not find any information ont hat issue and I wonder if this is > an issue related to pywin32 / PythonCOM ? I was told this is a support > request and not an issue. > Happy to learn if anybody else knows this problem and what to do. > > Thanks in advance > Christoph > > From sdementen at gmail.com Wed Nov 17 03:12:24 2021 From: sdementen at gmail.com (=?UTF-8?Q?S=C3=A9bastien_de_Menten?=) Date: Wed, 17 Nov 2021 09:12:24 +0100 Subject: [python-win32] returning #N/A to Excel via UDF Message-ID: I would like to return #N/A values to excel via an UDF written in python (via xlwings) Returning a `VARIANT(pythoncom.VT_ERROR, 2042)` from the UDF results in an empty cell. Is there within pywin32/pythoncom an equivalent of VBA `CVErr(xlErrNA)` ? S?bastien -------------- next part -------------- An HTML attachment was scrubbed... URL: From phenome321 at gmail.com Wed Nov 17 09:31:12 2021 From: phenome321 at gmail.com (Victor Liu) Date: Wed, 17 Nov 2021 14:31:12 +0000 Subject: [python-win32] mail Sensitivity doesn't work as expected(can not set the sensitivity label) Message-ID: Hi guys, Gratitude to all the work of the library. I am trying to use it to send out some emails, but I have encountered this issue which might be a bug. It can be represented by this minimum working example. import win32com.client outlook = win32com.client.Dispatch('outlook.application') mail = outlook.CreateItem(0) mail.To = 'victor at example.com' mail.Subject = 'Sample Email' mail.HTMLBody = '

This is HTML Body

' mail.Body = "This is the normal body" mail.CC = 'victor at example.com' mail.Sensitivity = 1 mail.Send() This works well expect the mail.sensitivity =1 part, so it pops up a window to set the sensitivity label(Bear in mind, not all outlook has set up this restriction). This makes the process is impossible to automate. My understanding is mail.sensitivity =1 is for that Azure label. Please let me know if I missed something. Thank you all in advance. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven at manross.net Wed Nov 17 18:35:13 2021 From: steven at manross.net (Steven Manross) Date: Wed, 17 Nov 2021 23:35:13 +0000 Subject: [python-win32] returning #N/A to Excel via UDF In-Reply-To: References: Message-ID: <618e67190e2c41a1bc15555f7bfd18f3@manross.net> While I don?t have any useful suggestions here? I thought I would link the thread I found in the xlwings github thread that the author looks to have been working on with them already. https://github.com/xlwings/xlwings/issues/776 HTH Steven From: python-win32 On Behalf Of S?bastien de Menten Sent: Wednesday, November 17, 2021 1:12 AM To: python-win32 Subject: [python-win32] returning #N/A to Excel via UDF I would like to return #N/A values to excel via an UDF written in python (via xlwings) Returning a `VARIANT(pythoncom.VT_ERROR, 2042)` from the UDF results in an empty cell. Is there within pywin32/pythoncom an equivalent of VBA `CVErr(xlErrNA)` ? S?bastien -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven at manross.net Wed Nov 17 18:20:05 2021 From: steven at manross.net (Steven Manross) Date: Wed, 17 Nov 2021 23:20:05 +0000 Subject: [python-win32] mail Sensitivity doesn't work as expected(can not set the sensitivity label) In-Reply-To: References: Message-ID: <0583e7150a1b4effa87fc788f1a5ee7e@manross.net> As best I remember, Microsoft considers the programming of Mail tasks (and most Outlook automation) as a security risk/issue, and limits your access to certain parts because so many people (malware writers) wrote stuff to programmatically abuse Outlook for unsavory (Evil?!?) purposes. However, fear not... I have successfully and programmatically used something called Outlook Redemption to unlock these secured areas of Outlook when I have needed to do something Microsoft didn't allow you to programmatically perform in the past (I'm not the author of the software nor do I get a commission for referring people to it). I don't think I even have that software loaded anymore. https://www.dimastr.com/redemption/home.htm There is a "developer version" usable for free, but it is a saleable product. Read the license, use it at your own risk (since ultimately Microsoft locked certain aspects of Outlook off for a reason - and loading this product would in essence bypass those restrictions). The author of Redemption has great KB articles and examples, but most of my programming with this product was in VBScript, so I'm not going to be able to share examples in Python. A lot of what I was doing with the module was reading messages out to files or querying particular MAPI attributes for use with a Microsoft Exchange-based SpamAssassin filter - or - Monitor a mailbox for incoming emails and perform some task with the messages in a separate system (provided the message met certain criteria). The product has also been on the market for 10+ years, so it's a very mature product (NOT like a 1.0 or 0.9 version). HTH Steven From: python-win32 On Behalf Of Victor Liu Sent: Wednesday, November 17, 2021 7:31 AM To: python-win32 at python.org Subject: [python-win32] mail Sensitivity doesn't work as expected(can not set the sensitivity label) Hi guys, Gratitude to all the work of the library. I am trying to use it to send out some emails, but I have encountered this issue which might be a bug. It can be represented by this minimum working example. import win32com.client outlook = win32com.client.Dispatch('outlook.application') mail = outlook.CreateItem(0) mail.To = 'victor at example.com' mail.Subject = 'Sample Email' mail.HTMLBody = '

This is HTML Body

' mail.Body = "This is the normal body" mail.CC = 'victor at example.com' mail.Sensitivity = 1 mail.Send() This works well expect the mail.sensitivity =1 part, so it pops up a window to set the sensitivity label(Bear in mind, not all outlook has set up this restriction). [Image removed by sender. image] This makes the process is impossible to automate. My understanding is mail.sensitivity =1 is for that Azure label. Please let me know if I missed something. Thank you all in advance. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ~WRD0002.jpg Type: image/jpeg Size: 823 bytes Desc: ~WRD0002.jpg URL: From timr at probo.com Wed Nov 17 21:01:01 2021 From: timr at probo.com (Tim Roberts) Date: Wed, 17 Nov 2021 18:01:01 -0800 Subject: [python-win32] mail Sensitivity doesn't work as expected(can not set the sensitivity label) In-Reply-To: References: Message-ID: Victor Liu wrote: > > > Gratitude to all the work of the library. I am trying to use it to > send out some emails, but I have encountered this issue which might be > a bug. It can be represented by this minimum working example. > It might perhaps be a bug, but it is not a bug in Python.? All you're doing is controlling the Outlook object model. > ... mail.Sensitivity = 1 > mail.Send() > > This works well expect the |mail.sensitivity =1|?part, so it pops up a > window to set the sensitivity label(Bear in mind, not all outlook has > set up this restriction). > ... > > This makes the process is impossible to automate. > > My understanding is |mail.sensitivity = 1|?is for that Azure label. > Please let me know if I missed something. > That is certainly not how it is defined.? MailItem.Sensitivity is an enumeration of type OISensitivity, where 0=normal, 1=personal, 2=private, and 3=confidential.? Here's the doc page: https://docs.microsoft.com/en-us/office/vba/api/outlook.olsensitivity There is no additional meaning assigned to it.? It's possible your copy of Outlook might have additional add-ons that change this behavior, but there is nothing you can do about that with COM. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: From sdementen at gmail.com Thu Nov 18 02:01:23 2021 From: sdementen at gmail.com (=?UTF-8?Q?S=C3=A9bastien_de_Menten?=) Date: Thu, 18 Nov 2021 08:01:23 +0100 Subject: [python-win32] returning #N/A to Excel via UDF In-Reply-To: <618e67190e2c41a1bc15555f7bfd18f3@manross.net> References: <618e67190e2c41a1bc15555f7bfd18f3@manross.net> Message-ID: Indeed useful to give more context. It is to find a fix for this bug that I have posted this message On Thu, Nov 18, 2021, 00:35 Steven Manross wrote: > While I don?t have any useful suggestions here? I thought I would link > the thread I found in the xlwings github thread that the author looks to > have been working on with them already. > > > > https://github.com/xlwings/xlwings/issues/776 > > > > HTH > > > > Steven > > *From:* python-win32 *On > Behalf Of *S?bastien de Menten > *Sent:* Wednesday, November 17, 2021 1:12 AM > *To:* python-win32 > *Subject:* [python-win32] returning #N/A to Excel via UDF > > > > I would like to return #N/A values to excel via an UDF written in python > (via xlwings) > > Returning a `VARIANT(pythoncom.VT_ERROR, 2042)` from the UDF results in an > empty cell. > Is there within pywin32/pythoncom an equivalent of VBA `CVErr(xlErrNA)` ? > > > > S?bastien > -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.tatarnikov at gmail.com Fri Nov 19 05:31:51 2021 From: and.tatarnikov at gmail.com (=?UTF-8?B?0JDQvdC00YDQtdC5INCi0LDRgtCw0YDQvdC40LrQvtCy?=) Date: Fri, 19 Nov 2021 13:31:51 +0300 Subject: [python-win32] Create new log under Applications and Services Logs and write messages to it Message-ID: Hello all, It is possible to write messages to Windows Logs -> Application event log with pywin32, and actually it is pretty easy. But after living some time with such a solution it became clear that an ability to create a custom log under Applications and Services Logs and write to it will help a lot (e.g. such logs have simpler management than Application log). Unfortunately, I haven't found a lot of manuals/examples on how to achieve this using pywin32 with modern python (3.8+) on modern windows (10 on desktops, server 2019). If anyone could kindly point me to any proper APIs/examples/docs I will really appreciate it. Thanks, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: From phenome321 at gmail.com Mon Nov 22 06:07:33 2021 From: phenome321 at gmail.com (Victor Liu) Date: Mon, 22 Nov 2021 11:07:33 +0000 Subject: [python-win32] mail Sensitivity doesn't work as expected(can not set the sensitivity label) In-Reply-To: <1106505747.266340.1637303222648@mail1.libero.it> References: <1637188201.879725133@f12.my.com> <1106505747.266340.1637303222648@mail1.libero.it> Message-ID: Hi Marchi This is a genius idea, it works well for me. Thank you very much. Regards Victor > On 19 Nov 2021, at 06:27, marchi.gianluca at libero.it wrote: > > Hope this can clarify. Let me know if not. > >> Il 18/11/2021 14:40 Victor Liu ha scritto: >> >> >> Hi Marchi >> >> Thanks for mentioning your workaround. Is it possible to share your template with me or even just the part that controls sensitivities ? Yes, we are going to use template very soon, which will make a lot of things easier, so if there is a workaround in the template, then that is possibly the best solution so far. >> >> Regards >> Victor >> >>> On 17 Nov 2021, at 22:30, marchi.gianluca at libero.it wrote: >>> I had the same problem. I have not found any way to control azure information with python. >>> Anyway my workaround was to manually save a template with the correct sensitivity, with all other info (to, subject, body test,etc.) empty. >>> Then in the code I do not create a new email but recall the template. >>> Hotel this could help. >>> >>> -- >>> Inviato da Libero Mail per Android >>> >>> Mercoled?, 17 Novembre 2021, 11:02PM +01:00 da Victor Liu phenome321 at gmail.com : >>> >>> Hi guys, >>> >>> Gratitude to all the work of the library. I am trying to use it to send out some emails, but I have encountered this issue which might be a bug. It can be represented by this minimum working example. >>> >>> import win32com.client >>> >>> outlook = win32com.client.Dispatch('outlook.application') >>> mail = outlook.CreateItem(0) >>> mail.To = 'victor at example.com ' >>> mail.Subject = 'Sample Email' >>> mail.HTMLBody = ' >>> This is HTML Body >>> >>> ' >>> mail.Body = "This is the normal body" >>> mail.CC = 'victor at example.com ' >>> mail.Sensitivity = 1 >>> mail.Send() >>> This works well expect the mail.sensitivity =1 part, so it pops up a window to set the sensitivity label(Bear in mind, not all outlook has set up this restriction). >>> >>> This makes the process is impossible to automate. >>> >>> My understanding is mail.sensitivity =1 is for that Azure label. Please let me know if I missed something. >>> >>> Thank you all in advance. >>> Victor >>> _______________________________________________ >>> python-win32 mailing list >>> python-win32 at python.org >>> https://mail.python.org/mailman/listinfo/python-win32 >> >