win32com

Using win32client SAPI.SpVoice with multi-threading leads to pywintypes.com_error

青春壹個敷衍的年華 提交于 2019-12-13 04:11:23
问题 I am trying to use a thread with wincl 's built-in voice system. However I am running into this error: pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, None) which I can't seem to decipher. Here is my code: import win32com.client as wincl import time, threading def ten_second_timer(): t =threading.Timer(10, ten_second_timer) speak = wincl.Dispatch("SAPI.SpVoice") speak.Speak("10 seconds have passed") t.start() t =threading.Thread(target = ten_second_timer) t

Setting the color of a large number of Excel Cells quickly

强颜欢笑 提交于 2019-12-13 03:58:26
问题 Quickly setting values and colors of a large number of Excel cells using win32com I have to calculate the values and set back ground colors of a large number of excel cells. In practice the value of each cell is calculated from information in a database. The color of the cell is set in accordance with HOW that data was calculated. i.e. which bits of the database were used to calculate the value. There will be values that are the same but where calculated via different methods. The background

“show formulas” in excel using python & win32com

主宰稳场 提交于 2019-12-13 03:55:29
问题 How can display/show all of the formulas in an Excel workbook using Python3 and win32com.client, like I can do interactively with Cntrl-` I believe I have to use the Windows DisplayFormulas Property but I don't know how to access the ActiveWindow to do this in Python. Here is the code I have up to open a spreadsheet and the first workbook and save it: import win32com.client excel = win32com.client.Dispatch("Excel.Application") wb = excel.Workbooks.Open(wb_path) ws_index_list = [1] wb

Python win32com PivotCache.CreatePivotChart() error: 'Exception occurred'

﹥>﹥吖頭↗ 提交于 2019-12-13 03:45:38
问题 There is one other question from Sep 2017 that addresses this same problem but does not have an answer: create a pivotchart with python win32com I have tried several approaches to get this working so I want to explain these and hopefully get some insight from someone on how to get this working. This does not appear to be a well worn path so I do not have high hopes. Environment details: Windows 10 Office 2013 Anaconda 3.6 I use win32com.client.gencache.EnsureDispatch('Excel.Application') but

Naming conflict (_FilterDatabase) when feeding Excel with Data from win32com

一个人想着一个人 提交于 2019-12-13 03:20:31
问题 I wanted to create a quick script that pulls data from standardized forms (word docs/docxs) and transports them into an Excel Sheet, with an attached sheet that does some calculating. Everything works pretty well, with one exception: I want to be able to filter the results for specific project numbers, user initials or other datapoints, but when I add a filter over the Excel sheet, whenever I run it from Python, I get a "Naming conflict" error messagee and have to choose a new name for "

Memory Leak in Threaded COM Object with Python

时光怂恿深爱的人放手 提交于 2019-12-12 13:37:57
问题 I am creating a COM client within a thread and performing several operations with this client. Each thread is spawned from a server that uses Python's socketserver module which has built-in threading support. When I am loading and using this COM object there is an expected spike in memory usage by python.exe. With 10 concurrent threads there is a peak in memory usage of about 500Mb. However when the operations are finished and the COM object is apparently released, there are 50Mb of

why does this script not work with threading python

我的未来我决定 提交于 2019-12-12 11:33:28
问题 so i've been trying to ifnd a way to access task manager. I've tried a few methods including the wmi module and the windows tasklist but neither suit my need. wmi is way too slow and tasklist becomes too slow when i access it multiple times concurrently in something using multiprocessing. so i found this script which works quite nicely but i can't get it to work with threading. import win32com.client strComputer = "." objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")

create a pivotchart with python win32com

依然范特西╮ 提交于 2019-12-12 09:49:49
问题 is there anyone can give a example code for creating a pivotchart in excel? I have got an example to create a pivottable with pivottable, it works , while when I try to create a pivotchart in the same ways, it will always failed! import win32com.client import os Excel = win32com.client.gencache.EnsureDispatch('Excel.Application') win32c = win32com.client.constants wb = Excel.Workbooks.Add() Sheet1 = wb.Worksheets.Add() TestData = [['Country','Name','Gender','Sign','Amount'], ['CH','Max' ,'M',

Python win32com opening Excel with Bloomberg plugin

那年仲夏 提交于 2019-12-12 08:48:37
问题 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 "#NAME?" errors). Manually uninstalling and reinstalling the plugin works, but copying the VBA code from the recorded macro leads to a "Run-time error '13': Type mismatch" error. I can click the End button and everything runs fine, but I want to

Python - Create Shortcut with arguments

烂漫一生 提交于 2019-12-12 08:15:30
问题 Using win32com.client, I'm attempting to create a simple shortcut in a folder. The shortcut however I would like to have arguments, except I keep getting the following error. Traceback (most recent call last): File "D:/Projects/Ms/ms.py", line 153, in <module> scut.TargetPath = '"C:/python27/python.exe" "D:/Projects/Ms/msd.py" -b ' + str(loop7) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 570, in __setattr__ raise AttributeError("Property '%s.%s' can not be set." %