pywin32

Use Python to Write VBA Script?

烂漫一生 提交于 2019-11-29 10:36:35
问题 This might be a bit of a stretch, but is there a possibility that a python script can be used to create VBA in MS Excel (or any other MS Office product that uses VBA) using pythonwin or any other module. Where this idea came from was pythons openpyxl modules inability to do column autowidth. The script I have creates a workbook in memory and eventually saves it to disc. There are quite a few sheets and within each sheet, there are quite a few columns. I got to thinking....what if I just use

Multiple django sites on Apache / Windows / mod_wsgi - problem with win32

无人久伴 提交于 2019-11-29 10:26:48
I have two django sites that use the same database and share some of the code. The main parent site is an extranet for staff and contractors, while the second site exposes some of the data to a few of our partners. I have managed to set up sites to work but found that if I launched Apache and went into the main site, then the partner site wouldn't work, returning an "Internal Server Error". If I restarted and went into the partner site, then the main site wouldn't work. So I guess they are conflicting over resources. The server log (see bottom) shows that it is a problem with the win32/lib

Unprotect an Excel file programmatically

不问归期 提交于 2019-11-29 08:28:47
We're getting an Excel file from a client that has open protection and Write Reserve protection turned on. I want to remove the protection so I can open the Excel file with the python xlrd module. I've installed the pywin32 package to access the Excel file through COM, and I can open it with my program supplying the two passwords, save, and close the file with no errors. I'm using Unprotect commands as described in MSDN network, and they're not failing, but they're also not removing the protection. The saved file still requires two passwords to open it after my program is done. Here's what I

Setting a cell's fill RGB color with pywin32 in excel?

让人想犯罪 __ 提交于 2019-11-29 08:21:20
I'm avoiding using any other set of modules. What I am trying to do is set a cell's color in Excel, using the pywin32 libary. So far I've found how to get the cells color: print xl.ActiveSheet.Cells(row, column).interior.color and you can set it simply by assigning it in a similar fashion: xl.ActiveSheet.Cells(row, column).interior.color = 0 #black My question is how to set the cell's colour in RGB? I need something called a ColorTranslator to OLE , but I don't know how to access system.drawing since it seems like it's a .NET thing. http://msdn.microsoft.com/en-us/library/system.drawing

Keyboard event not sent to window with pywin32

独自空忆成欢 提交于 2019-11-29 08:19:24
I've wrote A code that gets the HWND from any program I want. So thats how I got the hwnd if your asking. The following code should bring up device manger and send the down arrow to the program. But it doenst. It does bring up the device manager but it doesnt send the arrow down key to the program, at least nothing happens. If I change the hwndMain number with the hwnd code of a notepad window, the code does work and sends the arrow down key import win32api import win32con import win32gui import time hwndMain = 133082 hwndChild = win32gui.GetWindow(hwndMain, win32con.GW_CHILD) win32gui

“Not implemented” Exception when using pywin32 to control Adobe Acrobat

这一生的挚爱 提交于 2019-11-29 07:53:50
问题 I have written a script in python using pywin32 to save pdf files to text that up until recently was working fine. I use similar methods in Excel. The code is below: def __pdf2Txt(self, pdf, fileformat="com.adobe.acrobat.accesstext"): outputLoc = os.path.dirname(pdf) outputLoc = os.path.join(outputLoc, os.path.splitext(os.path.basename(pdf))[0] + '.txt') try: win32com.client.gencache.EnsureModule('{E64169B3-3592-47d2-816E-602C5C13F328}', 0, 1, 1) adobe = win32com.client.DispatchEx('AcroExch

Python: copying from clipboard using tkinter without displaying window

*爱你&永不变心* 提交于 2019-11-29 07:37:30
Running Python 3.4 on Windows 7. I need to copy what's stored in the clipboard to a variable in my python program. I've seen on Stack Overflow that that can be done either with pywin32 or tkinter. Since tkinter is part of the python standard library, I decided that that was the better of the two since the user won't have to install an external module. Here's the code for getting the clipboard data in tkinter: import tkinter number = tkinter.Tk().clipboard_get() This works fine except a blank tkinter window pops up every time this executes. 1) Why is this happening? Normally tkinter doesn't

python3 ctype CreateWindowEx simple example

♀尐吖头ヾ 提交于 2019-11-29 07:22:38
I have googled for some time but could not find simple example of python3 ctypes and Win32 API for creating and showing window. Please point me to good link or show code here. Thanks in advance! This is most easy to do with the win32gui module and its friends, win32api and win32con. There's no need to write your own ctypes wrappers to the Windows API. The simplest Petzold style app comes out something like this: import win32api, win32con, win32gui class MyWindow: def __init__(self): win32gui.InitCommonControls() self.hinst = win32api.GetModuleHandle(None) className = 'MyWndClass' message_map =

Associating my Windows computer to a wifi AP with Python

旧城冷巷雨未停 提交于 2019-11-29 06:57:47
I'm trying to write a python script that can make my computer associate to a wireless access point, given the name as a string. For example, I might specify I want to connect to linksys , and my script would cause the computer to do that. I looked at this question, but wasn't able to understand what to do from looking at the links provided. Can somebody point me in the right direction? I decided to take Paulo's suggestion and try using Powershell/the command line. I found an article about connecting to a network via the command line. From the command line, you can do: netsh wlan connect

os.path.islink on windows with python

六眼飞鱼酱① 提交于 2019-11-29 06:15:23
On Windows 7 with Python 2.7 how can I detect if a path is a symbolic link? This does not work os.path.islink() , it says it returns false if false or not supported and the path I'm providing is definitely a symbolic link so I'm assuming it's not supported on windows? What can I do? The root problem is that you're using too old a version of Python. If you want to stick to 2.x, you will not be able to take advantage of new features added after early 2010. One of those features is handling NTFS symlinks. That functionality was added in 3.2 in late 2010. (See the 3.2 , 3.1 , and 2.7 source for