win32com

Paste Excel clip to body of an email through Python

浪尽此生 提交于 2020-01-03 03:00:29
问题 I am using win32com.client in Python to send an email. However I want the body of the email to be a table (HTML- formatted table), I can do it in an Excel first and then copy and paste (but how?), or directly edit the corresponding Pandas data frame. newMail.body = my_table which is a Pandas data frame didn't work. So I'm wondering if there is smarter ways for example, to combine Excel with Outlook apps within Python? Cheers, 回答1: There are solutions regarding how to convert your Excel table

python win32com how to set winhttp option value

大憨熊 提交于 2020-01-02 13:08:28
问题 from win32com.client import Dispatch winhttp = Dispatch('winhttp.winhttprequest.5.1') print winhttp.Option(6) #True winhttp.Option(6) = False #SyntaxError <----------------how to set Option(6) to false print winhttp.Option(6) winhttp.Open('GET', 'http://google.com', False) winhttp.Send() print winhttp.responsetext =========================================== output: invalid syntax: winhttp.py, line 13, pos 11 File "c:\Users\***\Desktop\winhttp.py", line 13, in ? set winhttp.Option(6) = False

py2exe/pyinstaller and DispatchWithEvents

烈酒焚心 提交于 2020-01-01 07:01:11
问题 I have a program that uses the win32com library to control iTunes, but have been having some issues getting it to compile into an executable. The problem seems to revolve around using DispatchWithEvents instead of Dispatch . I've created a very simple program to illustrate my problem: import win32com.client win32com.client.gencache.is_readonly = False #From py2exe wiki class ITunesEvents(object): def __init__(self): self.comEnabled = True def OnCOMCallsDisabledEvent(self, reason): self

How can I use Microsoft Word's spelling/grammar checker programmatically?

删除回忆录丶 提交于 2020-01-01 03:21:05
问题 I want to process a medium to large number of text snippets using a spelling/grammar checker to get a rough approximation and ranking of their "quality." Speed is not really of concern either, so I think the easiest way is to write a script that passes off the snippets to Microsoft Word (2007) and runs its spelling and grammar checker on them. Is there a way to do this from a script (specifically, Python)? What is a good resource for learning about controlling Word programmatically? If not, I

Python - How to turn-on Excel Auto Filter on cells in non-first row?

ぐ巨炮叔叔 提交于 2019-12-31 05:11:54
问题 I'm trying to turn-on Auto-Filter in Excel for some cells at row 5, preferably using Python Win32. For example: from win32com.client import Dispatch xl = Dispatch("Excel.Application") xl.Workbooks.Open(<file name>) xl.ActiveWorkbook.ActiveSheet.Range('A5:D5').AutoFilter() xl.ActiveWorkbook.Close(SaveChanges=1) del(xl) It still creates Auto Filter in the first row. Update: It works correctly, see comments. I know that it is possible to set AutoFilter using ActiveSheet.Columns property, but it

win32com.client.Dispatch Class Label

雨燕双飞 提交于 2019-12-31 03:49:45
问题 I am trying to connect to a COM object using python. More specifically, I am using ASCOM standard drivers to connect to a MaxDome II, and do not know how to reference this driver. In this link the author uses "Celestron.Telescope" as their parameter for the win32com.client.Dispatch instantiation. My question is how to find this string. I understand that it is related to the installed drivers, which are installed on the computer, but I don't how to locate the specific string. Is there a way to

dll load errors in python executable made from pywin32

别等时光非礼了梦想. 提交于 2019-12-31 02:50:15
问题 I created python executables with py2exe with both 64bit python interpreter and 32 bit python interpreter. In my program, I use the module pywin32 com , and so I dl'ed and installed both the 64bit and 32bit versions of the program prior to creating the executable. The 64bit exe works fine, but the 32 bit one has the following problem: Traceback (most recent call last): File "program.py", line 11, in <module> File "win32com\__init__.pyc", line 5, in <module> File "win32api.pyc", line 12, in

Error “The object invoked has disconnected from its clients” - automate IE 8 with python and win32com

微笑、不失礼 提交于 2019-12-30 08:18:09
问题 I would like to automate Internet Explorer 8 (using python 2.7 on Windows 7) machine. Here is my code after a post found on SO: import sys, time from win32com.client import WithEvents, Dispatch import pythoncom import threading stopEvent=threading.Event() class EventSink(object): def OnNavigateComplete2(self,*args): print "complete",args stopEvent.set() def waitUntilReady(ie): if ie.ReadyState!=4: while 1: print "waiting" pythoncom.PumpWaitingMessages() stopEvent.wait(.2) if stopEvent.isSet()

Python - Extra Excel chart series with win32com

馋奶兔 提交于 2019-12-30 07:49:58
问题 I'm writing some code for an assignment, and I need to create a simple column chart in Excel. This afternoon I found win32com (amazing tool by the way), but I've been suffering from either the lack of documentation about it, or my lack of luck to find it ^^ I'm playing around with the charts, and I think I've managed to do what I want, with a little exception: the function I wrote always creates 2 series of columns. This is what I've got: xlBook = xlApp.Workbooks.Add() xlSheet = xlBook.Sheets

Python - Extra Excel chart series with win32com

随声附和 提交于 2019-12-30 07:49:33
问题 I'm writing some code for an assignment, and I need to create a simple column chart in Excel. This afternoon I found win32com (amazing tool by the way), but I've been suffering from either the lack of documentation about it, or my lack of luck to find it ^^ I'm playing around with the charts, and I think I've managed to do what I want, with a little exception: the function I wrote always creates 2 series of columns. This is what I've got: xlBook = xlApp.Workbooks.Add() xlSheet = xlBook.Sheets