andreas has asked for the wisdom of the Perl Monks concerning the following question:

I want to extract the content of Powerpoint slides using Perl (ActiveState Perl 5.8.4.810) and OLE-Storage_Lite 0.14.

The following script works fine with Office XP:

... my $slide = $presentation->slides($slideNumber); if ($slide->shapes($shapeNumber)->TextFrame->HasText) { $slide->shapes($shapeNumber)->TextFrame->{TextRange}->{Text}; ...
Running this script with Office 2003 the HasText condition is always false, so I can't get text from Powerpoint 2003.

Any ideas?

thanks in advance

Andreas

Replies are listed 'Best First'.
Re: Problem with OLE and Powerpoint 2003
by jimbojones (Friar) on Jul 15, 2005 at 15:17 UTC
    hi

    The following worked for me under Office 2003.

    use Win32::OLE qw/ in /; my $file = 'C:\Documents and Settings\jim\My Documents\perlmonks_examp +les\sample.ppt'; my $ppt = Win32::OLE->new('PowerPoint.Application', sub {$_[0]->Quit;} +); $ppt->{Visible} = 1; my $presentation = $ppt->Presentations->Open($file); die "Cannot open File '$file': $! " unless ( $presentation ); my $slide = $presentation->slides(1); foreach my $shape ( in $slide->Shapes ) { if ($shape->TextFrame->HasText) { print "Text:", $shape->TextFrame->{TextRange}->{Text} , "\n"; } } __DATA__ Text:This is the sample title Text:This is the sample text.
    ... where I had a simple, one-slide PPT with a title "This is the sample title" and a text box with "THis is the Sample Text"

    The issue may be that the "Shapes" method returns a collection of shapes, and your indexing of it ($slide->shapes($shapeNumber)) may not work under Office 2003. That's only a guess

    see also: The MSDN PPT reference docs

    - j

      This works. Many Thanks