Questions tagged [win32com]

win32com is a Python module to interact with Windows COM components. It is part of the Python for Win32 (pywin32) project by mhammond.

win32com is a Python module to interact with windows COM components. It is part of the Python for Win32 (pywin32) extensions project by mhammond, which provides access to many of the Windows APIs from Python.

The Python COM package can be used to interface to almost any COM program (such as the MS-Office suite), write servers that can be hosted by any COM client (such as Visual Basic or C++), and has even been used to provide the core ActiveX Scripting Support.

1868 questions
5
votes
1 answer

How to use Python's win32com to "save as" an Excel file?

I have a small Python code to open an Excel file. Now I want to "Save As" with a different name but same format. How do I do that?
fk.
  • 51
  • 1
  • 1
  • 2
5
votes
3 answers

Memory Leak in Threaded COM Object with Python

I am creating a COM client within a thread and performing several operations with this client. Each thread is spawned from a server that uses Python's socketserver module which has built-in threading support. When I am loading and using this COM…
Michael David Watson
  • 3,028
  • 22
  • 36
5
votes
3 answers

Python Create Access database using win32com

I want to create an Access database (*.accdb) from within a Python script. Using win32com and Dispatch I can call the application. However, I cant find anything on how to create a new database. access =…
Thomas Becker
  • 471
  • 3
  • 8
  • 16
5
votes
2 answers

python Win32 Save

I am using python to open an excel file and make some changes and then I need to save it. I can get everything done except the save part. How do I get python to save the file. If I save it manual I get the pop up box and I can click save, but I…
Trying_hard
  • 8,931
  • 29
  • 62
  • 85
5
votes
1 answer

Registered COM object not recognized by python's win32com.client.dispatch()

I'm trying to load a COM object with Python. I'm using win32com.client.Dispatch("Name.Of.Object") to load it, and the COM object has been registered with regsvr32 and appears as an entry in my registry in both HKLM/CLSID and HKLM/Wow6432Node/CLSID.…
user1496547
  • 139
  • 1
  • 1
  • 5
5
votes
4 answers

Export Charts from Excel as images using Python

I have been trying to export the charts from Excel as an image file (JPG or ING) in Python. I am looking at the WIn32com. Here is what I have till now. import win32com.client as win32 excel = win32.gencache.EnsureDispatch("Excel.Application") wb =…
Parikshit
  • 543
  • 1
  • 7
  • 16
4
votes
1 answer

How to programmatically set Excel Sensitivity Labels using Python?

Recently our IT dept has applied a policy where we have to specify Sensitivity Label in Excel. This caused a disruption to my automated py codes to generate personalised excel files. Besides using Excelwriter to write into the file, i also use…
faridzridzwan
  • 41
  • 1
  • 3
4
votes
0 answers

Microsoft Excel cannot access the file with pywin32

I'm facing a odd behavior when trying to Open and Save an Excel file. The message, when opening and saving is always the same, doesn't matter if it's in a network drive or in the C:\. (-2147352567, 'Exception occurred.', (0, u'Microsoft Excel',…
Eug_Zazou
  • 155
  • 1
  • 11
4
votes
1 answer

Extracting HTML table data from email to csv file, 1st column values to row headers, using Python

I am trying to read through an outlook folder and get the ReceivedTime,CC,Subject,HTMLBody but extract the table into columns. I can pull 1) ReceivedTime,CC,Subject,HTMLBody into a dataframe and I can do 2) Extract the HTMLBody tables into a…
KLC2021
  • 47
  • 1
  • 5
4
votes
1 answer

Python, Pyinstaller creating shortcuts in windows

I am making a python script that creates a shortcut (.lnk) file, using win32com.client module, I am using pyinstaller to convert it to exe. I'm also using Tkinter, so I need --tk support in pyinstaller. Pyinstaller doesn't seem to work with --tk and…
Saúl Pilatowsky-Cameo
  • 1,224
  • 1
  • 15
  • 20
4
votes
2 answers

How to properly wait to check if an Excel instance has closed after attempting to?

I'm using the Python standard library modules and the pythoncom and win32com.client modules from the PyWin32 package to interact with Microsoft Excel. I get a list of the running Excel instances as COM object references and then when I want to close…
user7393973
  • 2,270
  • 1
  • 20
  • 58
4
votes
1 answer

R reticulate package not finding Python win32com module

I'm trying to use reticulate in R to access Python's win32com (in order to read password-protected Excel documents), but am failing at the first hurdle. Although my code works fine in Python, when trying to use it in reticulate, the win32com module…
Matt
  • 518
  • 2
  • 5
  • 19
4
votes
1 answer

Python: ValueError: microsecond must be in 0..999999 while using win32com

I'm currently trying calculate the leadtime of all outlook messages within a specific outlook folder using python. In general the script runs fine however, after roundabout 2000 emails I received the following error (part of code): import…
Rudo
  • 41
  • 1
  • 4
4
votes
1 answer

Reading and writing Windows "tags" with Python 3

In Windows image files can be tagged. These tags can be viewed and edited by right clicking on a file, clicking over to the Details tab, then clicking on the Tags property value cell. I want to be able to read and write these tags using Python…
4
votes
2 answers

How to copy chart from excel and paste it as chart into powerpoint (not image) using python

I have an excel file which generates chart based on the data available, the chart name is thisChart. I want to copy thisChart from excel file to the ppt file. Now I know the 2 ways to do that ie VBA and python(using win32com.client). The problem…
Prashant Kumar
  • 501
  • 8
  • 26