Tuesday, November 16, 2010

voici ma blogue: rock paper python using win32com

i read this guy's much better written blog and liked it so much that i was inspired to create something similar to it for the picky ones like me who neither want to use vba nor ruby for scripting on windows.

the articles will mostly be a series of quick and dirty "how-tos" using examples from whichever vba scripts i happen upon or any other sources i consider interesting enough.
finally, i hope it convinces david to abandon vba for python once and for all.

in order to play rock paper python, get win32com for your site's installed version of python from here if necessary. we'll be working with  ms excel in this first example.


>>> from win32com.client import Dispatch

>>> xl = Dispatch('Excel.Application')
>>> xl.Visible = 1
>>> xl.Workbooks.Add()
>>> var1 = 3453 
>>> var2 = 98
>>> xl.Cells(1,1).Value = var1/var2
>>> xl.Workbooks.Close()
>>> xl.Quit()
# done