win32com

excel access denied with win32 python pywin32

自作多情 提交于 2020-01-24 20:03:43
问题 My code is #Opens template for creating final report excel = win32.dynamic.Dispatch('Excel.Application') template = os.path.abspath((folderpath+'\Poop.xlsx')) wb = excel.Workbooks.Open(template) freshws= wb.Sheets("Fresh") #Sheet names must match perfectly secws= wb.Sheets("sec") cur.execute("Select * from FIRALL") freshdata=list(cur.fetchall()) #writes to the first sheet datarowlen=0 for i,a in enumerate(freshdata): datarowlen = len(a) for j,b in enumerate(a): freshws.Cells(i+1,j+1).Value =

How to introspect win32com wrapper?

安稳与你 提交于 2020-01-23 10:57:52
问题 I have a device, which records spectroscopic data and is controlled by a 3rd-party application. For automization purposes, I want to use the COM interface of the application to retrieve the data in Python. Since there is no proper documentation for using the API from Python, I collected the following code from different web sources, which successfully obtains the first frame: comtypes.client.GetModule(('{1A762221-D8BA-11CF-AFC2-508201C10000}', 3, 11)) import comtypes.gen.WINX32Lib as

Component creation fails under UAC admin, works without UAC elevation

天涯浪子 提交于 2020-01-15 11:42:51
问题 I have a .NET COM dll with a custom registration procedure so it gets registered under HKEY_CURRENT_USER\Software\Classes as opposite to HKEY_LOCAL_MACHINE . So there are the following keys (current user is the admin on the Windows 7 PC): HKEY_CURRENT_USER\Software\Classes\My.ProgId\CLSID HKEY_CURRENT_USER\Software\Classes\CLSID\{XYZZYZYZYZ-YZYZY-ZYZYZY} etc If I build a simple C++ client: hr = CLSIDFromProgID(OLESTR("My.ProgId"), &clsid); and run it without UAC elevation (Windows 7) , it

Using python win32com can't make two separate tables in MS Word 2007

徘徊边缘 提交于 2020-01-15 06:52:06
问题 I am trying to create multiple tables in a new Microsoft Word document using Python. I can create the first table okay. But I think I have the COM Range object configured wrong. It is not pointing to the end. The first table is put before "Hello I am a text!", the second table is put inside the first table's first cell. I thought that returning a Range from wordapp will return the full range, then collapse it using wdCollapseStart Enum which I think is 1. (I can't find the constants in Python

Python Export Excel Sheet Range as Image

社会主义新天地 提交于 2020-01-14 03:16:07
问题 So it seems there's something weird going on with PIL ImageGrab.grabclipboard() import win32com.client from PIL import ImageGrab o = win32com.client.Dispatch('Excel.Application') o.visible = False wb = o.Workbooks.Open(path) ws = wb.Worksheets['Global Dash'] ws.Range(ws.Cells(1,1),ws.Cells(66,16)).CopyPicture() img = ImageGrab.grabclipboard() imgFile = os.path.join(path_to_img,'test.jpg') img.save(imgFile) When I run this, I notice that if I ctrl-V , the image is actually correctly saved on

Is there a way to automate BLF to CSV conversion in Vector CANoe?

眉间皱痕 提交于 2020-01-13 16:56:52
问题 My first approach was using python-can (as it added support for parsing BLF files with 2.0.0 release) like this: import can filename = "logfile.blf" logging = can.BLFReader(filename) for msg in logging: print(msg) but that resulted in an error that I reported to the developer. BLF format is proprietary and somewhat secret so I understand supporting it in an open-source library can be problematic. So then I looked into doing it using a solution provided by Vector : COM , but so far haven't

Read PST files from win32 or pypff

落花浮王杯 提交于 2020-01-13 06:15:10
问题 I want to read PST files using Python. I've found 2 libraries win32 and pypff Using win32 we can initiate a outlook object using: import win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox = outlook.GetDefaultFolder(6) The GetDefaultFolder(6) gets the inbox folder. And then I can use this folders functions and attribute to work with. But what I want is to give my own pst files which pywin32(or any other library) can read. Here it only connects

Python win32com.client.Dispatch looping through Word documents and export to PDF; fails when next loop occurs

不想你离开。 提交于 2020-01-12 05:51:31
问题 Based on the script here: .doc to pdf using python I've got a semi-working script to export .docx files to pdf from C:\Export_to_pdf into a new folder. The problem is that it gets through the first couple of documents and then fails with: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', u'Command failed', u'wdmain11.chm', 36966, -2146824090), None) This, apparently is an unhelpful general error message. If I debug slowly it using pdb, I can loop through all files and export

Export Charts from Excel as images using Python

巧了我就是萌 提交于 2020-01-09 07:08:31
问题 I have been trying to export the charts from Excel as an image file (JPG or ING) in Python. I am looking at the WIn32com. Here is what I have till now. import win32com.client as win32 excel = win32.gencache.EnsureDispatch("Excel.Application") wb = excel.Workbooks.Open("<WORKSHEET NAME>") r = wb.Sheets("<SHEET NAME>").Range("A1:J50") # Here A1:J50 is the area over which cart is r.CopyPicture() This is where I am stuck. I need to copy the selected range to a file now. Any help or pointers

Export Charts from Excel as images using Python

Deadly 提交于 2020-01-09 07:07:05
问题 I have been trying to export the charts from Excel as an image file (JPG or ING) in Python. I am looking at the WIn32com. Here is what I have till now. import win32com.client as win32 excel = win32.gencache.EnsureDispatch("Excel.Application") wb = excel.Workbooks.Open("<WORKSHEET NAME>") r = wb.Sheets("<SHEET NAME>").Range("A1:J50") # Here A1:J50 is the area over which cart is r.CopyPicture() This is where I am stuck. I need to copy the selected range to a file now. Any help or pointers