Win32::PowerPoint - helps to convert texts to PP slides
use Win32::PowerPoint; # invoke (or connect to) PowerPoint my $pp = Win32::PowerPoint->new; # set presentation-wide information $pp->new_presentation( background_forecolor => [255,255,255], background_backcolor => 'RGB(0, 0, 0)', pattern => 'Shingle', ); # and master footer if you prefer (optional) $pp->set_master_footer( visible => 1, text => 'My Slides', slide_number => 1, datetime => 1, datetime_format => 'MMMMyy', ); (load and parse your slide text) # do whatever you want to do for each of your slides foreach my $slide (@slides) { $pp->new_slide; $pp->add_text($slide->title, { size => 40, bold => 1 }); $pp->add_text($slide->body); $pp->add_text($slide->link, { link => $slide->link }); # you may add pictures $pp->add_picture($file, { left => 10, top => 10 }); } $pp->save_presentation('slide.ppt'); $pp->close_presentation; # PowerPoint closes automatically
Win32::PowerPoint helps you to create a PowerPoint presentation. You can add texts/pictures incrementally to your slides.
Invokes (or connects to) PowerPoint.
Explicitly connects to (or invoke) PowerPoint.
Explicitly disconnects from PowerPoint, and closes it if this module invoked it.
Creates a new (probably blank) presentation. Options are:
You can specify background colors of the slides with an array ref of RGB components ([255, 255, 255] for white) or formatted string ('255, 0, 0' for red). You can use '(0, 255, 255)' or 'RGB(0, 255, 255)' format for clarity. These colors are applied to all the slides you'll add, unless you specify other colors for the slides explicitly.
You can use 'masterbkgforecolor' and 'masterbkgbackcolor' as aliases.
You also can specify default background pattern for the slides. See Win32::PowerPoint::Constants (or MSDN or PowerPoint's help) for supported pattern names. You can omit 'msoPattern' part and the names are case-sensitive.
Saves the presentation to where you specified. Accepts relative path. You might want to save it as .pps (slideshow) file to make it easy to show slides (it just starts full screen slideshow with a doubleclick).
Explicitly closes the presentation.
Adds a new (blank) slide to the presentation. Options are:
You can set colors just for the slide with these options. You can use 'bkgforecolor' and 'bkgbackcolor' as aliases.
You also can set background pattern just for the slide.
Adds (formatted) text to the slide. Options are:
of the Textbox.
See 'decorate_range' for other options.
Adds file to the slide. Options are:
of the picture. width and height are optional.
If set to true, the picture will be linked, otherwise, embedded.
Prepends/Appends text to the current Textbox. See 'decorate_range' for options.
Arranges (master) footer. Options are:
If set to true, the footer(s) will be shown, and vice versa.
Specifies the text part of the footer(s)
If set to true, slide number(s) will be shown, and vice versa.
If set to true, the date time part of the footer(s) will be shown, and vice versa.
Specifies the date time format of the footer(s) if you specify one of the registered ppDateTimeFormat name (see Win32::PowerPoint::Constants or MSDN for details). If set to false, no format will be used.
Decorates text of the range. Options are:
Boolean.
Integer.
See above for the convention.
Font name of the text. You can use 'name' as an alias.
One of the 'left' (default), 'center', 'right', 'justify', 'distribute'.
You can use 'align' as an alias.
hyperlink address of the Text.
(This method is mainly for the internal use).
This module uses Win32::OLE internally. You can fully control PowerPoint through the following accessors. See Win32::OLE and other appropriate documents like intermediate books on PowerPoint and Visual Basic for details (after all, this module is just a thin wrapper of them). If you're still using old PowerPoint (2003 and older), try Record New Macro (from the Tools menu, then, Macro, and voila) and do what you want, and see what's recorded (from the Tools menu, then Macro, and Macro... submenu. You'll see Visual Basic Editor screen).
Record New Macro
Tools
Macro
Macro...
returns an Application object.
print $pp->application->Name;
returns a current Presentation object (maybe ActivePresentation but that's not assured).
$pp->save_presentation('sample.ppt') unless $pp->presentation->Saved; while (my $last = $pp->presentation->Slides->Count) { $pp->presentation->Slides($last)->Delete; }
returns a current Slide object.
$pp->slide->Export(".\\slide_01.jpg",'jpg'); $pp->slide->Shapes(1)->TextFrame->TextRange ->Characters(1, 5)->Font->{Bold} = $pp->c->True;
As of 0.10, you can pass an index number to get an arbitrary Slide object.
returns Win32::PowerPoint::Constants object.
This module itself seems to work under the Cygwin environment. However, MS PowerPoint expects paths to be Windows-ish, namely without /cygdrive/. So, when you load or save a presentation, or import some materials with OLE (native) methods, you usually need to convert them by yourself. As of 0.08, Win32::PowerPoint::Utils has a convert_cygwin_path function for this. Win32::PowerPoint methods use this function internally, so you don't need to convert paths explicitly.
convert_cygwin_path
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2006- by Kenichi Ishigaki
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Win32::PowerPoint, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::PowerPoint
CPAN shell
perl -MCPAN -e shell install Win32::PowerPoint
For more information on module installation, please visit the detailed CPAN module installation guide.