win32com

Sort a Range of Cells, win32com.client

霸气de小男生 提交于 2019-12-23 02:36:23
问题 I am trying to sort a range of cells in python using win32com: Code I've been using is: sheet.Range("A1:B8").Sort(Key1=sheet.Range("B1"), Orientation=constants.xlAscending) which is working. It sorts the range of cells by the second column: When I want, is to sort Descending instead of Ascending: sheet.Range("B8:A1").Sort(Key1=sheet.Range("B1"), Orientation=constants.xlDescending) but for some weird reason, it switches the data from each column and doesn't sort the values that were initially

python win32com outlook 2013 SendUsingAccount return exception

冷暖自知 提交于 2019-12-22 12:23:50
问题 While working on a simple mail automation with python and win32com api, I had an issue with SendUsingAccount. It was ignored or, worse, generating an error when I upgraded from windows 7 to windows 10. Here is my original code import win32com.client o = win32com.client.Dispatch("Outlook.Application") oacctouse = None for oacc in o.Session.Accounts: if oacc.SmtpAddress == "sender@mail.com": oacctouse = oacc break Msg = o.CreateItem(0) if oacctouse: Msg.SendUsingAccount = oacctouse if to: Msg

Win32 PrintDlg, PrintDlgEx, Crashing and quirkiness

ぐ巨炮叔叔 提交于 2019-12-22 09:49:05
问题 I'm tasked with solving the following issue: My application crashes when running on a 64 bit machine when the PrintDlg() function is called. After digging and hair pulling, I've decided the best solution is to replace the original calls of PrintDlg() with its bigger brother, PrintDlgEx(). Doing so fixes one problem (it no longer crashes!), but causes another. When I execute the code, it is not showing the print dialog, just returning a success code, and giving me all of the information for my

how can i remove a deskband and delete its dll without restart the explorer process?

依然范特西╮ 提交于 2019-12-22 00:29:49
问题 I created a deskband on taskbar. When I want to update the DLL of the deskband, I hide it , unregister it,but unfortunately the explorer still keeps this DLL in the memory. How can I update the dll without restart the explorer process? There is any Windows api for such a case? 回答1: "Unsupported" (aka hack) solution (C/C++): HWND hWnd = FindWindowW(L"Shell_TrayWnd", NULL); if (hWnd != NULL) PostMessageW(hWnd, WM_TIMER, 0x18, 0); This will force the call of CoFreeUnusedLibraries function in the

Add signature to outlook email with python using win32com

时间秒杀一切 提交于 2019-12-21 19:45:25
问题 Does anyone know how to add an email signature to an email using win32com? import win32com.client as win32 outlook = win32.Dispatch('outlook.application') mail = outlook.CreateItem(0) mail.To = 'TO' mail.Subject = 'SUBJECT' mail.HTMLbody = 'BODY' mail.send 回答1: Outlook signatures are not exposed through the Outlook Object Model. The best you can do is read the signature from the file system and add its contents to the HTML body appropriately. Keep in mind that two HTML strings must be merged,

Python win32com and 2-dimensional arrays

≯℡__Kan透↙ 提交于 2019-12-21 05:44:16
问题 When using python and win32com to automate the software form Adobe one encounters problem with passing arrays of 2d coordinates. If one looks at code that Adobe ships for visual basic (VB) its simple. A simplified example for drawing a line in Illustrator would look as follows: Set appObj = CreateObject("Illustrator.Application") Set docObj = appObj.Documents.Add Set pathItem = docObj.PathItems.Add pathItem.SetEntirePath Array(Array(0.0, 0.0), Array(20.0, 20.0)) Now the naive assumption is

Error while working with excel using python

末鹿安然 提交于 2019-12-21 05:06:12
问题 while my script is updating one excel same time if i am going to do any other work manually with another excel error occurs i am using dispatch from win32com.client import Dispatch excel = Dispatch('Excel.Application') excel.Visible = True file_name="file_name.xls" workbook = excel.Workbooks.Open(file_name) workBook = excel.ActiveWorkbook sheet=workbook.Sheets(sheetno) I am geting error like this (, com_error(-2147418111, 'Call was rejected by callee.', None, None) Is there is any way to

Load Excel add-in using win32com from Python

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 04:59:13
问题 I've seen from various questions on here that if an instance of Excel is opened from Python using: xl = win32com.client.gencache.EnsureDispatch('Excel.Application') xl.Visible = True wb = xl.Workbooks.Open('Test.xlsx') Then it does not load the default add-ins. I've tried forcing my add-in to load by instead running: xl = win32com.client.gencache.EnsureDispatch('Excel.Application') xl.Visible = True addin = xl.Workbooks.Open('C:/path/addIn.xll') wb = xl.Workbooks.Open('Test.xlsx') However,

how to get attributes from win32com.client.dispatch(“Shell.Application”)

╄→гoц情女王★ 提交于 2019-12-21 02:26:29
问题 I am trying to control my device manager programmatic through python (ie disable and re-enabling devices). However I am having trouble figuring out what are the attributes in the namespace of the "win32com.client.Dispatch("Shell.Application")". All i know how to do is get the name and print it. I did a debugging run through the code but i couldn't find anything useful. Here is what I have so far import win32com.client shell = win32com.client.Dispatch("Shell.Application") control_panel = shell

Adding Excel Sheets to End of Workbook

瘦欲@ 提交于 2019-12-20 04:09:12
问题 I am trying to add excel worksheets to the end of a workbook, reserving the first sheet for a summary. import win32com.client Excel = win32com.client.DispatchEx('Excel.Application') Book = Excel.Workbooks.Add() Excel.Visible = True Book.Worksheets(3).Delete() Book.Worksheets(2).Delete() Sheet = Book.Worksheets(1) Sheet.Name = "Summary" Book.Worksheets.Add(After=Sheet) Sheet = Book.Worksheets(2) Sheet.Name = "Data1" This code adds the new sheet to the left, despite using After=Sheet , and when