Skip to content
Advertisement

Tag: win32com

Extracting all data validation formula values(dropdown) from excel sheet

How can we extract the data validation dropdown values(not just formulas/references or a single valued formula result) from a given excel sheet using python? Currently openpyxl helps us to get the formulas but not the values directly. It even fails in cases where file contain extensions(extLst) to the OOXML specifications that are not supported.These datavalidation formulas can contain functions like

Converting Excel to PDF with pywin32 [Error]

I try to export one of my xlsx files as PDF with pywin32: Unfortunately I get this com_error: In the end I want to do use this conversion on 30 xlsx files at once. I know how to write the loop for this but can not fix the above mentioned error. Answer When using Python paths on Windows, you need

Timestamp of Outlook emails using Python

Is it possible to use Python to extract timestamps from received email? I’m using the following code but to no avail: I only get one date published repeatedly for each email. (i.e., 2021-11-22, 2021-11-22, 2021-11-22…….) Any help will be much appreciated. Answer Well, of course – you only retrieve ReceivedTime once:

Python: Open Excel file with win32

My code was working yesterday but today when I tried running it again it threw me an error and I’ve try to figure this out but I couldn’t. Hope you can help me out here. Thanks much! And this is the error the system threw: —> 11 wb = excel.Workbooks.Open(file) com_error: (-2147352567, ‘Exception occurred.’, (0, ‘Microsoft Excel’, “Sorry, we couldn’t

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: This would pop-up an instance of excel and I could continue working in Python. But suddenly, today my scripts are failing with the following: The code

How can I use SetJob in win32print?

I want to clear or delete print jobs using Python. But how can I get JobID? win32print.SetJob(hPrinter, JobID , Level , JobInfo , Command) How could I run this code? Answer Starting from your code, I’ve managed to create a small script that deletes any print job on any (local) printer (I’ve tested it and it works). Here it is

How to insert a picture into Excel at a specified cell position with python (Anaconda) use vba

I try to use this link with vba code but in Python it doesn’t work. AttributeError Traceback (most recent call last) in () 9 sheet.Cells(20, 20).Select 10 #obj1=sheet.Shapes.AddPicture (r’C:/Users/Home/Desktop/picture.jpg’, False, True, 10, 3, 100, 100) —> 11 obj1=wb.ActiveSheet.Pictures.Insert(r’C:/Users/Home/Desktop/picture.jpg’) 12 obj1.ShapeRange 13 obj1.ShapeRange.LockAspectRatio = msoTrue AttributeError: ‘function’ object has no attribute ‘Insert’ Answer Unless you absolutely need to use VBA, this

Python win32com constants

I’m currently wondering how to list the constants in win32com in python, for example using excel win32com.client.Dispatch(‘Excel.Application’) Is there a way to display all constants using win32com.client.Constants ? Or does someone know where i could find win32com’s documentation ? Because all the links I found are dead … Answer To find out what Com applications you can use… See http://timgolden.me.uk/pywin32-docs/html/com/win32com/HTML/QuickStartClientCom.html

Advertisement