Re: create Powerpoint via com

2007-09-02 Thread Alan Isaac
Well, my needs were very limited so the
result is too, but in case someone else
just needs to get started:
http://econpy.googlecode.com/svn/trunk/utilities/mso.py

Comments, suggestions, additions welcom.

Alan Isaac
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: create Powerpoint via com

2007-08-31 Thread kyosohma
On Aug 30, 11:55 pm, Alan Isaac [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  code

 OK, creating bulleted lists, or tables,
 or adding pictures is all straightforward.
 How about chart creation (in Ppt 2003)?
 I do not see how to do this with Python.

 Thanks,
 Alan

Alan,

You probably need to browse the COM object using PythonWin, which is a
part of the ActiveState distro. You can also use Python's builtin
function, dir, to find out various methods of COM.

Here's some info in messing with charts in Excel, which should be
similar to chart manipulation in PowerPoint.

http://mail.python.org/pipermail/python-win32/2005-June/003511.html
http://mail.python.org/pipermail/python-win32/2003-March/000839.html
http://www.thescripts.com/forum/thread21565.html
http://mathieu.fenniak.net/plotting-in-excel-through-pythoncom/

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: create Powerpoint via com

2007-08-31 Thread Alan Isaac
How about chart creation (in Ppt 2003)?
I do not see how to do this with Python.

[EMAIL PROTECTED] wrote:
 You probably need to browse the COM object using PythonWin, which is a
 part of the ActiveState distro. You can also use Python's builtin
 function, dir, to find out various methods of COM.
 
 Here's some info in messing with charts in Excel, which should be
 similar to chart manipulation in PowerPoint.
 
 http://mail.python.org/pipermail/python-win32/2005-June/003511.html
 http://mail.python.org/pipermail/python-win32/2003-March/000839.html
 http://www.thescripts.com/forum/thread21565.html
 http://mathieu.fenniak.net/plotting-in-excel-through-pythoncom/


Thanks!
Alan
-- 
http://mail.python.org/mailman/listinfo/python-list


create Powerpoint via com

2007-08-30 Thread Alan Isaac
Can someone point me to a simple example
or better yet tutorial for creating
a Powerpoint using Python.

Thanks,
Alan Isaac
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: create Powerpoint via com

2007-08-30 Thread kyosohma
Alan,

On Aug 30, 1:37 pm, Alan Isaac [EMAIL PROTECTED] wrote:
 Can someone point me to a simple example
 or better yet tutorial for creating
 a Powerpoint using Python.

 Thanks,
 Alan Isaac

You should check our the following for information on using COM
itself:

http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html

Core Python Programming by Chun has an example in it using Tkinter. I
did it a while back, so here's the source:


code

# Core Python Chp 23, pg 994
# ppoint.pyw

from Tkinter import Tk
from time import sleep
from tkMessageBox import showwarning
import win32com.client as win32

warn = lambda app: showwarning(app, 'Exit?')
RANGE = range(3, 8)

def ppoint():
app = 'PowerPoint'
ppoint = win32.gencache.EnsureDispatch('%s.Application' % app)
pres = ppoint.Presentations.Add()
ppoint.Visible = True

s1 = pres.Slides.Add(1, win32.constants.ppLayoutText)
sleep(1)
sla = s1.Shapes[0].TextFrame.TextRange
sla.Text = 'Python-to-%s Demo' % app
sleep(1)
slb = s1.Shapes[1].TextFrame.TextRange
for i in RANGE:
slb.InsertAfter(Line %d\r\n % i)
sleep(1)
slb.InsertAfter(\r\nTh-th-th-that's all folks!\r\n)

warn(app)
pres.Close()
ppoint.Quit()

if __name__ == '__main__':
Tk().withdraw()
ppoint()

/code

I recommend getting ActiveState's Python distro as it comes with an
IDE that can browse COM objects fairly easily.

Hope that helps!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: create Powerpoint via com

2007-08-30 Thread Alan Isaac
[EMAIL PROTECTED] wrote:
 Hope that helps!

Yes indeed.
Thanks!
Alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: create Powerpoint via com

2007-08-30 Thread Alan Isaac
[EMAIL PROTECTED] wrote:
 code

OK, creating bulleted lists, or tables,
or adding pictures is all straightforward.
How about chart creation (in Ppt 2003)?
I do not see how to do this with Python.

Thanks,
Alan
-- 
http://mail.python.org/mailman/listinfo/python-list