6 ms·
Automating Microsoft Office with Python
- mataug 13y agoThis was a talk at PyconIndia 2013
- ndefinite 13y agoDo you know where to find the recording? Converting macros to python sounds extremely useful
- mataug 13y agoThe recording should be available in a few days, check the mailing list, But the author didn't go into the details of how he converted macros to python.
- anymane 13y agoI did a bit of Excel programming in Python; a tool to extract, and sanity check, data from a spreadsheet, send it to a server and populate results back in the spreadsheet. The "Python Programming On Win32" book by Mark Hammond was a great resource http://shop.oreilly.com/product/9781565926219.do http://shop.oreilly.com/product/9781565926219.do
- woodchuck64 13y agoMisread this as "Automating Microsoft with Python" Knew Ballmer let the company down but didn't think it was that far.
- bryogenic 13y agoI'd be really interested in this if there were a way to get Python to render a ppt into a pdf. Basically, the goal would be to programmatically add a unique watermark to each ppt, render the pdf, and save it. Doing this for 100+ things is not worth the time but if Python can script it up it might be worth investigating. Looks like I need to go read the COM api a bit.
- orf 13y agoThis can be done really easily. I've done a lot of work with the Office COM API and Python, despite it being a bit weird at times its pretty nice to work with. The best bit (IMO) is you can record a macro within an Office application then translate that very very very easily to Python code, and it just works.
- mataug 13y agoThis is precisely what the author told during his talk today at PyconIndia2013. He said that he wrote a bunch of macros and translated then into python
- harrytuttle 13y agowordInstance.ActiveDocument.SaveAs(filename + ".pdf", 17) 17 is the magic number for PDF output. There is a constant in VSTO and COM for it but I can't remember what it is. Need Office 2007 with save as pdf addon installed or vanilla 2010/2013. People always say that APIs are the future and Microsoft are dead etc but Microsoft stuff is usually chock full of extensibility and knee deep in documentation. To give you an idea, it took me merely two days to extend word 2010 via VSTO with a fully GUI and ribbon integrated semantic template engine that allows documents to be bound to our public API and rendered server side or client side online and offline. Do that in Google Apps? Yeah right... also my solution will still be supported until 2023!
- bliti 13y agoI did a simple application for a client that was a simple JSON-to-Excel dump. It was a breeze. Took me about a day to do it. From zero to finished.
- qq66 13y agoAt LiveLoop we've gone insanely deep into COM to build real-time collaboration for PowerPoint, and while the interface is powerful there are mysteries at every level. These presentations (especially the last) are very impressive ion light of that.
- josteink 13y agoAt LiveLoop we've gone insanely deep into COM I can say this too and we do stuff not even Microsoft thought was possible. while the interface is powerful there are mysteries at every level. The interfaces are indeed powerful (not to leave out annoyingly inconsistent). That said, there are only mysteries when you go oh so far. If play by a few safe rules, you should be mostly safe unless you have very long lived processes which starts mixing COM code with other code digging beneath the API for things which isn't otherwise possible. It can be argued that both the best and the worst part of the .NET Framework is how it makes COM interop seem so utterly seamless. It's bound to land you in a trap sooner or later.
- vardhanvarma 13y agoThere is a open sourced screen reader called NVDA, which really puts this to good use.
- unlimitedbacon 13y agoYears ago, at my first internship, we were assigned to copy fields of information out of hundreds of PDF files and compile them into a single spreadsheet. While my coworker began dutifully trudging away, I started googling and found out about the COM API and the Python library. I spent the rest of my time writing a script to automate the task. The silly and wonderful thing about the Office API is that it doesn't work silently, but instead performs the operations on screen as if they were being done by a human being. The article explains this. There's something very satisfying about seeing the reaction of your boss as he watches the computer do the work on its own, as if its being operated by a ghost. Now I know what it must have been like to see a player piano a hundred years ago.
- ams6110 13y agoKind of like the CSI computers that show every fingerprint and mugshot on the screen as the system searches for a match.
- benjarrell 13y agoI always think of the IO requirements doing that would impose.
- agumonkey 13y agoIn VBA there's a command to toggle screen redrawing, isn't it exposed through COM ? very impactful on performance, although I too like to witness high speed visual feedback of automated processing. The social implications are surprising too.
- nhebb 13y agoIn case anyone is interested, pg wrote the SpamBayes Outlook add-in in Python about 10 years ago: http://spambayes.sourceforge.net/ http://spambayes.sourceforge.net/
- redman25 13y agoUnfortunately win32 API is Windows specific.
- noisy_boy 13y agoFor PowerPoint 2007, you need to add the below line (like in the example for Excel) for the window to be visible: Application.Visible = 1
- scorpion032 13y agoJust as interesting are some of the visualisations, the author (of this ipnb) has done for some of the media houses in India. Done using powerpoint, but for a print publication, as good as it could be. (which are linked within this ipynb.)
- regularfry 13y agoTangentially, I'm convinced there's a worthwhile (small) business opportunity in hooking up py.test to Excel to Fix The Spreadsheet Problem(tm). Not something I can iterate on right now, though.
- clebio 13y agoWhat is The Spreadsheet Problem?
- regularfry 13y agoBig, important, expensive problems being "solved" by non-programmers without a validation safety-net.