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
106
votes
12 answers

ImportError: No module named win32com.client

I am currently using python 2.7 and trying to open an Excel sheet. When using the code below: import os from win32com.client import Dispatch xlApp = win32com.client.Dispatch("Excel.Application") xlApp.Visible = True # Open the file we want in…
user3194189
  • 1,161
  • 2
  • 7
  • 8
77
votes
14 answers

.doc to pdf using python

I'am tasked with converting tons of .doc files to .pdf. And the only way my supervisor wants me to do this is through MSWord 2010. I know I should be able to automate this with python COM automation. Only problem is I dont know how and where to…
nik
  • 8,387
  • 13
  • 36
  • 44
76
votes
5 answers

Clearly documented reading of emails functionality with python win32com outlook

I'm trying to understand outlook interaction through win32com better. I've been unable to find clear documentation that allows me to utilise win32com to read emails effectively, from my current investigation it seems like a fairly regular sentiment…
Phoenix
  • 4,386
  • 10
  • 40
  • 55
30
votes
8 answers

Can't close Excel completely using win32com on Python

This is my code, and I found many answers for VBA, .NET framework and is pretty strange. When I execute this, Excel closes. from win32com.client import DispatchEx excel = DispatchEx('Excel.Application') wbs =…
sacabuche
  • 2,781
  • 1
  • 27
  • 35
29
votes
7 answers

python-win32com excel com model started generating errors

Over the last few days, I have been working on automating the generation of some pivot tables for a number of reports. Boiled down to the minimum, the following code was working without issue: import win32com.client objExcelApp =…
Chris
  • 490
  • 1
  • 5
  • 11
26
votes
2 answers

win32.Dispatch vs win32.gencache in Python. What are the pros and cons?

I have been recently using win32com.client from python as an API for windows applications but am struggling to understand some basic things. I had been using it with a program called WEAP, in the following way import…
Juan Ossa
  • 1,153
  • 1
  • 10
  • 14
26
votes
2 answers

Send email to multiple recipients using win32com module in Python

I am using win32com to send emails after my code is done. However, I cannot figure out how to send it to more than 1 person. Now I can only add myself in cc, but not in the recipient list. Here is my code: import win32com.client import datetime as…
lsheng
  • 3,539
  • 10
  • 33
  • 43
22
votes
4 answers

Why am I suddenly getting a no attribute 'CLSIDToPackageMap' error with win32com.client?

The code import win32com.client as win32 Excel = win32.gencache.EnsureDispatch('Excel.Application') used to work, but now it produces the error: AttributeError: 'module' object has no attribute 'CLSIDToPackageMap' what's going on?
theVerse
  • 904
  • 1
  • 7
  • 14
20
votes
3 answers

Using win32com with multithreading

I am working on a web app with CherryPy that needs to access a few applications via COM. Right now I create a new instance of the application with each request, which means each request waits 3 seconds for the application to start and 0.01 for the…
stenci
  • 8,290
  • 14
  • 64
  • 104
20
votes
1 answer

Read Outlook Events via Python

Outlook has some things to desire - like showing multiple month view I decided to give it a try by pulling out the event data via Python (and then figure a way to display it nicely). Google is giving poor results. My goals are: read a shared…
Norfeldt
  • 8,272
  • 23
  • 96
  • 152
18
votes
4 answers

Interesting "getElementById() takes exactly 1 argument (2 given)", sometimes it occurs. Can someone explain it?

#-*- coding:utf-8 -*- import win32com.client, pythoncom import time ie = win32com.client.DispatchEx('InternetExplorer.Application.1') ie.Visible = 1 ie.Navigate('http://ieeexplore.ieee.org/xpl/periodicals.jsp') time.sleep( 5…
Tre Mi
  • 181
  • 1
  • 3
17
votes
5 answers

Error Connecting to Outlook via COM

I have the following python code o = win32com.client.Dispatch("Outlook.Application") ns = o.GetNamespace("MAPI") profile = ns.Folders.Item("Profile Name") tasks = profile.Folders.Item("Tasks") print tasks.Items When i run it, the script crashes…
Nuno Furtado
  • 4,548
  • 8
  • 37
  • 57
16
votes
3 answers

List all methods in COMobject

Is it possible? Something in the lines of : import win32com.client ProgID = "someProgramID" com_object = win32com.client.Dispatch(ProgID) for methods in com_object: print methods I got the com_object.__dict__, which lists: [_oleobj_,…
f.rodrigues
  • 3,499
  • 6
  • 26
  • 62
15
votes
7 answers

Issue in using win32com to access Excel file

everyone! I have been using the win32com.client module in Python to access cells of an Excel file containing VBA Macros. A statement in the code xl = win32com.client.gencache.EnsureDispatch("Excel.Application") has been throwing an error: …
wordplayer
  • 163
  • 1
  • 2
  • 6
14
votes
4 answers

python win32 COM closing excel workbook

I open several different workbooks (excel xlsx format) in COM, and mess with them. As the program progresses I wish to close one specific workbook but keep the rest open. How do I close ONE workbook? (instead of the entire excel application) xl =…
Razor Storm
  • 12,167
  • 20
  • 88
  • 148
1
2 3
99 100