win32com

How to use COM from python win32com or comtypes to access an IRTDServer?

情到浓时终转凉″ 提交于 2021-02-07 20:00:44
问题 Environment Windows 10 + python 3.6.3 64 bit (also tried 32 bit). I am a python developer trying to use COM for (nearly) the first time and hit this huge blocker. Problem I have had various errors when trying to use an IRTDServer implemented in a dll (not written by me), via either win32com or comtypes . Using win32com turned out to be more difficult. I have an included an example unittest for both libraries below. Accessing the server from Excel 2016 works as expected; this returns the

'proper' & reliable way to get all installed windows programs in Python?

柔情痞子 提交于 2021-02-05 20:31:38
问题 I've seen numerous ways of retrieving installed programs on WinXP+ in python. What is the proper and most robust way of doing this? Currently I'm accessing HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall and reading each of the keys from there to get a list. (I've been told this isn't the proper way of doing things) I've seen examples of using WMI/Win32com to do this as well but have seen comments along with those implementations that WMI might be turned off on certain machines

Register a 32-bit COM class for use in 64-bit Python without Administrator rights

女生的网名这么多〃 提交于 2021-01-29 19:38:24
问题 I'm making a Python script that uses SAP's GUI scripting API through win32com. The first usage is like this: from win32com.client import Dispatch objWrapper = Dispatch("SapROTWr.SapROTWrapper") This works fine when using a 32-bit Python interpreter, but not when using a 64-bit interpreter, which gives me a "Class not registered" error. Is there any way to do this, specially without Administrator privileges? The default answer will probably be something like "A 64-bit process can't load a 32

Python win32com 'Invalid number of parameters'

可紊 提交于 2021-01-29 03:33:30
问题 I am trying to use win32com to convert multiple xlsx files into xls using the following code: import win32com.client f = r"./input.xlsx" xl = win32com.client.gencache.EnsureDispatch('Excel.Application') wb = xl.Workbooks.Open(f) xl.ActiveWorkbook.SaveAs("./somefile.xls", FileFormat=56) which is failing with the following error: Traceback (most recent call last): File "xlsx_conv.py", line 6, in <module> xl.ActiveWorkbook.SaveAs("./somefile.xls", FileFormat=56) File "C:\python27\lib\site

Write to MS Access table, python win32com

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 03:07:51
问题 I'm playing around with win32com.client for python to try to write/insert a row to a MS Access table. I've found an example of how to connect and query an Access table here. Basically, their code slightly modified for my own use is: import win32com.client connection = win32com.client.Dispatch(r'ADODB.Connection') DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=c:\\testdb.mdb;' connection.Open(DSN) recordset = win32com.client.Dispatch(r'ADODB.Recordset') recordset.Open('SELECT * FROM

TypeError: 'str' object is not callable with win32com interfacing with Attachmate

别来无恙 提交于 2021-01-28 21:26:38
问题 I'm using Python to try to automate Attachmate - EXTRA!, similar to how most do in VBA. I'm using the package pywin32 found here. I'm using the documentation of how OLE works with Attachmate (where both GetString and PutString methods can be found) here. My code: system = win32com.client.Dispatch("EXTRA.System") sess0 = system.ActiveSession product = sess0.screen.GetString(0, 1, 2) Produces the error: line13: product = sess0.screen.GetString(1, 1, 2) TypeError: 'str' object is not callable

Using Python to find and replace footnotes in word

女生的网名这么多〃 提交于 2021-01-28 12:16:59
问题 I am trying to use Python to hyperlink text in MS Word documents. I am currently using the win32com module, but I have become a little stuck on how to get the text from footnotes (and how to add a hyperlink). I have tried reading stuff from: https://msdn.microsoft.com/en-us/library/kw65a0we(VS.80).aspx https://msdn.microsoft.com/en-us/library/bb179107(v=office.12).aspx In an effort to see what the command might be. 回答1: Use footnotes = ActiveDocument.StoryRanges(wdFootnotesStory) footnotes

Python, How to close excel workbook if user prematurely closes the command prompt?

风流意气都作罢 提交于 2021-01-28 08:52:12
问题 Using Windows, I start a command prompt and run my script, which will open an excel file in the background. I do use a try/except/finally block to catch exceptions and finally close the workbook, but it seems that if I hit the red 'X' on the command prompt (before the code completely finishes running) that the excel workbook stays open. My best guess is that the code just completely stops executing, wherever it was at? This isn't completely uncommon for me to do. What happens is that I

Python win32com - application installed with both 32bit and 64bit versions

心已入冬 提交于 2021-01-28 03:24:26
问题 I am using pythons win32com module to automate Adobe Photoshop. This works fine on some machines (have had issues with it not working on users with limited windows account permissions, but thats another issue). But on machines with both the 32bit and 64bit versions of Photoshop installed, I am getting errors when trying to access com objects, not the Photoshop.Application object itself, but Photoshop.PhotoshopSaveOptions, and Photoshop.SolidColor com objects. The error I get is Server

Python: Insert object into excel in a specific row and column with win32com

柔情痞子 提交于 2020-12-13 05:11:20
问题 I'm using Python 3.5 and win32com to insert an object (.pdf file) into excel with the following method: Embedded_object.Add(ClassType=None, Filename=file_loction, Link=False, DisplayAsIcon=True, Left=3, Top=0, Width=50, Height=50) This works fine, however it always embeds the object in the A1 cell, is there a way to embed the object into a specific row and column using the above method? Edit: I also tried the following: worksheet.Range('A1:A1').Copy() worksheet.Paste(Destination=worksheet