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

How can we create multiple PDF files using different win32com instances?

I have been trying to create multiple pdf files using DispatchEx but when I try to test my code, it creates only first pdf file while all other requests fail with strange errors. What am I doing wrong and/or how can I effectively handle multiple…
J J
  • 43
  • 7
3
votes
1 answer

Creating new Python object when using win32COM

I'm using win32COM to send commands to a software called "Robot Structural Analysis". I am able to retrieve objects that is declared inside the application, but I cannot find a way to declare new instance of a class defined in the application's API.…
kai
  • 31
  • 2
3
votes
1 answer

Python refresh data in excel with external connection through add in doesnt work

I am using the following code to refresh data in excel file which uses external add in for receiving data. import sys, os, pandas as pd, numpy as np, time, win32com.client import win32com.client as w3c if __name__ == '__main__': your_file_path…
Zanam
  • 4,607
  • 13
  • 67
  • 143
3
votes
1 answer

Saving AutoCAD files (.dwg) using Python

I am using win32com to automate some simple tasks in AutoCAD. It's mostly been working quite well except for being able to save files. My goal is to open a (template) file, adjust it depending on what is needed then save the file as a .dwg in…
Jowizo
  • 57
  • 1
  • 5
3
votes
1 answer

Python script with Win32Com not running in task scheduler

Background: I am on Windows 7 and am trying to automate some email-related list updates. I have a python script that pulls-in emails, downloads certain attachments and sends me back a new email with some results. This all works great when I run the…
Paco
  • 443
  • 3
  • 10
3
votes
0 answers

mail.Attachments.Add(path) will lead to error when I used it twice

When I used win32com.client to send outlook emails with one than one attachments in Python, I want to add multiple attachments with twice "mail.Attachments.Add()" However, it will intermittently lead to an error that said "This file could not be…
Ziwei Wang
  • 31
  • 1
3
votes
1 answer

Error when running Python Program: com_error: (-2147023174, 'The RPC server is unavailable.', None, None)

I am working with Excel, Python, and Visio and when I run this simple code, I get an error of com_error: (-2147023174, 'The RPC server is unavailable.', None, None) This is the code I am running: for row in range(1,sheet3.nrows): if…
3
votes
2 answers

python3.6 create win32 shortcut with unicode

I have this python3.6 code that creates Windows shortcuts: from win32com.client import Dispatch path_to_target = r"C:\Program Files\ピチャーム\pycharm64.exe" path_to_shortcut = r"C:\Program Files\pycharm.lnk" shell = Dispatch("WScript.Shell") shortcut =…
Periodic Maintenance
  • 1,698
  • 4
  • 20
  • 32
3
votes
1 answer

How to resolve AttributeError when using win32com.client api for opening MS word 2016 and access formFileds?

I am working to automate report generation using python. In a word document, I need to update the Form Fields to complete the report generation. On using win32.com.client.gencache.EnsureDispatch api, I am not able to get the formFields from the word…
Ronak SHAH
  • 171
  • 2
  • 11
3
votes
2 answers

Listing Available Message Attributes with win32com.client

I have a directory with hundreds of Outlook emails stored in .msg format. I have a script to access specific attributes, e.g. SenderName, Subject etc, however the script fails upon certain files. After some investigation, the failing files are…
DeltaKilo
  • 113
  • 3
  • 12
3
votes
1 answer

Automating Simple Photoshop with Python

The business I work for creates laser engraved custom products. The engraver machine requires files to be in the psd format. Our website enables users to select a template and enter in what text they want. After they order, one of our workers opens…
jon_groth34
  • 43
  • 1
  • 2
  • 6
3
votes
1 answer

How to freeze the top row in an Excel using WIN32COM python package?

How to freeze the top row in an Excel using WIN32COM python package? Searched almost everywhere, but could find examples with other packages, but not with "from win32com.client.gencache import EnsureDispatch" this one.
3
votes
1 answer

How to iterate through emails and their attachments Python win32

I'm trying to find all emails sent to specific person ('Andrew' for demo purposes) and then to find attachment in each of this mail that contains string in its name (there are multiple attachments added to each mail). Here is the code:…
ugabuga77
  • 681
  • 2
  • 11
  • 19
3
votes
1 answer

How do I get all date related info from Outlook (Python, win32)

I'm trying to get date related info from messages that Python retrieves from Outlook but for some weird reason I cannot. It is strange because I can obtain all info about sender, email body, subject, cc, bc, attachment etc. but when it comes to…
ugabuga77
  • 681
  • 2
  • 11
  • 19
3
votes
0 answers

Python : ImportError: No module named 'win32types'

I try to use win32com to open word docs from python (3.5) I installed pywin32, pypiwin32, win32com and som others... I lauched > python pywin32_postinstall.py -install Nothing to do. When trying to launch makepy.py I always have the error > python…
Jice
  • 191
  • 4
  • 16