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
10
votes
3 answers

How to install win32com.client on Python 3.4 or Python 2.7

I tried to install win32com.client using the syntax below, but no success >>> pip install pywin32 SyntaxError: invalid syntax >>> pypiwin32 Traceback (most recent call last): File "", line 1, in pypiwin32 NameError: name…
Jen
  • 143
  • 1
  • 2
  • 7
10
votes
3 answers

Autocomplete for Automation objects in VS Code and Python

I have the Python Extensions for Windows installed. Within the PythonWin IDE I can get autocomplete on Automation objects (specifically, objects created with win32com.client.Dispatch): How can I get the same autocomplete in VS Code? I am using the…
Zev Spitz
  • 13,950
  • 6
  • 64
  • 136
10
votes
6 answers

No module named 'win32api'

In Python 3.4 from Anaconda, I created a program and it is giving me and import error each time I run it. Using Spyder. ImportError: No module named 'win32api' I already have the pywin32 installed. And I can see the win32api.pyd under…
10
votes
4 answers

How to choose the version of excel which win32com.client has to use in python?

I have an excel 2007 file(*.xlsx) which is to be opened through a python script. But the problem is I have two versions of MS office (2003 and 2007) installed in my computer. Although I tried to make Excel 2007 as the default application to open…
sam
  • 101
  • 1
  • 6
10
votes
3 answers

excel access denied with win32 python pywin32

My code is #Opens template for creating final report excel = win32.dynamic.Dispatch('Excel.Application') template = os.path.abspath((folderpath+'\Poop.xlsx')) wb = excel.Workbooks.Open(template) freshws= wb.Sheets("Fresh") #Sheet names must match…
Drfrink
  • 404
  • 1
  • 9
  • 25
9
votes
2 answers

Python running MessageQueue.Peek via win32com, how to get timeout right?

For starters, I would like to say if anyone can help here, you are incredible. General Question My Python program needs to interact with MSMQ. Basically, I want to peek at a queue, specifying a timeout if there's nothing in the queue. However,…
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
9
votes
4 answers

Python - Converting XLSX to PDF

I have always used win32com module in my development server to easily convert from xlsx to pdf: o = win32com.client.Dispatch("Excel.Application") o.Visible = False o.DisplayAlerts = False wb =…
DavidRguez
  • 1,070
  • 3
  • 12
  • 27
9
votes
2 answers

Python - Get list of all attributes/properties of a win32com class

I am a newbie in Python. I have to extract emails from Outlook and get all attributes/properties of the emails. Retrieving properties one by one, for the attributes/properties that I know they exist works fine (.Subject, .Body, etc.). But, I need to…
9
votes
2 answers

Asynchronous data through Bloomberg's new data API (COM v3) with Python?

Does anyone know how to get asynchronous data through Bloomberg's new data API (COM v3) with Python? I found this code below on wilmott.com and it works just fine, but it's for the old API version. Does anyone know the corresponding code for the new…
c00kiemonster
  • 22,241
  • 34
  • 95
  • 133
9
votes
1 answer

Python/win32com - Check if Program is Open

I have a script where I use win32com to interact with a COM service. It works as intended when the program is already open. I connect to it using win32com.client.dynamic.Dispatch, then interact with a document that should already be open. …
Scott B
  • 2,542
  • 7
  • 30
  • 44
9
votes
1 answer

How to call Excel VBA functions and subs using Python win32com?

My Excel workbook contains VBA subs and macros similar to those below; they sit in Module1. How to call them using Python win32com module? Public Sub setA1(ByVal s As String) ThisWorkbook.ActiveSheet.Range("A1").Value = s End Sub Public…
Yulia V
  • 3,507
  • 10
  • 31
  • 64
8
votes
2 answers

How to detect Windows is locked?

How to detect Windows is locked (Win+L or locked by screensaver)? Is it possible?
Charles Sungkono
  • 145
  • 2
  • 10
8
votes
2 answers

How to continuously monitor a new mail in outlook and unread mails of a specific folder in python

I want to check for a particular sender email and process it automatically wherever it arrives However, there may be some situation where my outlook was restarted, mean while i received mail from sender and marked as unread For continuous monitor…
sireesha
  • 135
  • 1
  • 2
  • 11
8
votes
2 answers

Why are some callable attributes not listed by the dir() function?

How come the dir() function in Python doesn't show all of the callable attributes? import win32com.client iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application") currentTrack =…
tponthieux
  • 1,502
  • 5
  • 18
  • 30
8
votes
1 answer

Python win32com opening Excel with Bloomberg plugin

I'm trying to automate construction of an Excel 2007 spreadsheet that uses the Bloomberg plugin to pull down live prices. The problem is that when I open Excel through win32com the Bloomberg plugin does not load (so all of the formulas end up with…
Bill
  • 81
  • 1
  • 2