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
4
votes
4 answers

Extract all the images in a docx file using python

I have a docx file which contains 6-7 images. I need to automate the extraction of images from this doc file. Is there any win32com ms word API for the same? Or any library that can accurately extract all the images in it? This is what I have tried…
Himanshu Poddar
  • 7,112
  • 10
  • 47
  • 93
4
votes
1 answer

Detecting Activity with mouse, keyboard and voice on windows

We have a module on Python (through win32) to detect user mouse and keyboard activity by GetLastInputInfo and GetTickCount. How can we register Voice activity in GetLastInputInfo? Or maybe can we add a synthesized input to update GetLastInputInfo…
Led
  • 662
  • 1
  • 19
  • 41
4
votes
2 answers

Downloading Email Attachments from Shared Folder - Python

I have the below code to download email attachments based on date sent and email subject criteria: from datetime import date, timedelta import os import win32com.client path = os.path.expanduser("C:\\Users\\xxxx\\Documents\\Projects\\VBA…
Saadiq
  • 101
  • 2
  • 15
4
votes
1 answer

How to Quit Excel with win32com, without saving?

When I do xl.Quit(), Excel always pops up with a prompt that ask whether or not I want to save. How do tell it I don't want to save? xl = Dispatch('Excel.Application') xl.Workbooks.Open('New Workbook.xlsx') # do some stuff xl.Quit()
Joe Chan
  • 133
  • 3
  • 11
4
votes
1 answer

Extracting CSV file inside ZIP file from mails' attachments in one go using Python

I found and modified a code to read CSV attachments file from Outlook application using Python. What happened in my case is: When I request data for a certain period, they will send me the monthly data of the requested period in separate emails…
4
votes
0 answers

How can I specify a post-uninstall script for a Python package with setuptools / pip?

I'm creating a Python package that registers a COM server after install using the approach described in Post-install script with Python setuptools. How can specify a post-uninstall (or pre-uninstall) script to unregister the COM server when the…
maf
  • 305
  • 1
  • 9
4
votes
1 answer

Call was rejected by callee in win32com if a dialog box is open or excel is otherwise waiting for the user

I need to determine if Excel is ready to accept a COM object from win32com in Python. For instance if a dialog box is open in excel, any call to a win32com function will cause a 'Call was rejected by callee' error. Through trial and error I have…
Burtski
  • 451
  • 5
  • 19
4
votes
1 answer

Count number of sheets in an Excel file using win32com.client

Using win32com.client, how can I count all the number of sheets in a excel file?
ichigo
  • 317
  • 2
  • 6
  • 17
4
votes
0 answers

How can I eliminate "UnpicklingError: invalid load key, '\x00'" in win32com?

I'm using the latest version of win32com on Windows 7 and Python 3.6. import win32com.client working fine until recently. I'm now getting an UnpicklingError exception. I've tried reinstalling the latest version globally as well as in a separate…
pandichef
  • 706
  • 9
  • 11
4
votes
1 answer

Retrieve Excel Workbook Connection Properties

I am attempting to grab the "Command Text" from the Connection Property window in an Excel file using python. However, I cannot find the object that contains this information. In the below picture I would like to retrieve the highlighted EXEC…
MattR
  • 4,887
  • 9
  • 40
  • 67
4
votes
1 answer

select any folder as startfolder for browsing (win32gui,win32com, SHGetFolderLocation)

I want to start with a folder e.g. C:\test instead of any of the predefined CSIDL_* folders. How can I achieve that? ''' python 3.6.2 ''' import os import win32gui from win32com.shell import shell, shellcon myfolder_pidl =…
AcK
  • 2,063
  • 2
  • 20
  • 27
4
votes
1 answer

Is there a way to automate BLF to CSV conversion in Vector CANoe?

My first approach was using python-can (as it added support for parsing BLF files with 2.0.0 release) like this: import can filename = "logfile.blf" logging = can.BLFReader(filename) for msg in logging: print(msg) but that resulted in an error…
z33k
  • 3,280
  • 6
  • 24
  • 38
4
votes
2 answers

Python WMI calls not working under Windows 7

I've run into a sticky problem using WMI (via win32com) in Python under Windows 7. I haven't been able to find a resolution for this. Here is my code: from win32com.client import GetObject def get_printers(computer): """ Get a list of printers…
Raceyman
  • 1,354
  • 1
  • 9
  • 12
4
votes
1 answer

How to read EXCEPINFO tuple in win32 error messages?

I am writing an app that interacts with Excel. However, I'm hitting an error that I can't track down. My traceback says: pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None) Using the com_error…
indigochild
  • 350
  • 1
  • 5
  • 21
4
votes
1 answer

python-pptx ".ppt" handling work around

I am currently attempting to pull text from .ppt and .pptx files. I am successfully using python-pptx in order to handle .pptx files, BUT according to its documentation, ".ppt files from PowerPoint 2003 and earlier won’t work." When creating a…