Adding Worksheets to an Excel Workbook
f.braennstroem at gmx.de
Fri Oct 13 11:10:43 CEST 2006
* wesley chun <wescpy at gmail.com> wrote:
>> just a small OT question coming from a linux openoffice
>> Does there exist something similar for powerpoint? Would be
>> nice, if anybody can direct me to more examples...
> see below for a PP example. you mentioned you were coming from a
> linux OOo system... are you trying to do COM stuff with OOo? i'm not
> familiar with it, but since they do support
> some level of VB-like scripting, i don't believe it's out of the question.
> one thing that i did forget to mention in my earlier message is that i
> use static dispatch for these apps. if you did not go and run the
> makepy utility, you would have to use dynamic dispatch, start your
> apps with win32com.client.Dispatch(), or, using the same import
> statement as below, win32.Dispatch().
> anyway, here is pretty much the same script as i sent earlier but for
> PowerPoint instead of Excel (the book has small examples for each of
> Excel, Word, PowerPoint, and Outlook):
> # based on ppoint.pyw in Core Python Programming, 2nd ed
> from time import sleep
> import win32com.client as win32
> def ppoint():
> ppoint = win32.gencache.EnsureDispatch('PowerPoint.Application')
> pres = ppoint.Presentations.Add()
> ppoint.Visible = True
> s1 = pres.Slides.Add(1, win32.constants.ppLayoutText)
> s1a = s1.Shapes.TextFrame.TextRange
> s1a.Text = 'Python-to-PowerPoint Demo'
> s1b = s1.Shapes.TextFrame.TextRange
> for i in range(3, 8):
> s1b.InsertAfter("Line %d\r\n" % i)
> s1b.InsertAfter("\r\nTh-th-th-that's all folks!")
> if __name__=='__main__':
Thanks! I am not able to try it out yet, but as soon as I
get access to my windows machine, I'll give it a try.
More information about the Python-list