UPDATE
After messing around for a while I was able to get the notes. I have updated the script below to reflect it
#!/usr/bin/perl -w # use strict; use Win32::OLE qw( in valof with CP_UTF8 ); Win32::OLE->Option( CP => CP_UTF8 ); $Win32::OLE::Warn = 3; use Win32::OLE::Const; my $ole_const = { %{ Win32::OLE::Const->Load("Microsoft PowerPoint 12.0 Object Libra +ry") }, %{ Win32::OLE::Const->Load("Microsoft Office 12.0 Object Library") + }, }; $ole_const->{ppShapeFormatPNG} = 2; # Create PowerPoint OLE server. OLE server should 'Quit' if the script + dies unexpectedly. my $ppt = Win32::OLE->GetActiveObject('Powerpoint.Application') || Win32::OLE->new( 'PowerPoint.Application', 'Quit' ) || die "Can't create PowerPoint OLE: $!\n"; # Powerpoint must be visible to work $ppt->{Visible} = 1; #set some variables $|=1; $0 = $^X unless ($^X =~ m%(^|[/\\])(perl)|(perl.exe)$%i); my ($progpath) = $0 =~ m%^(.*)[/\\]%; $progpath ||= "."; my $pptfile = "$progpath\\test.ppt"; my $width=800; my $height=600; my $saveas="PNG"; #Open the powerpoint file print "Opening $pptfile\n"; if(!-s $pptfile){die $!;} my $pres = $ppt->Presentations->Open( $pptfile ); if(!$pres){die $!;} #interate through the slides and save each slide as a PNG SLIDE: for my $slide ( in $ppt->ActivePresentation->Slides ) { my $num=$slide->{SlideNumber}; my $pngfile="$progpath\\slide$num\.$saveas"; print "Exporting Slide $num\n"; $slide->Export($pngfile,$saveas,$width,$height); my $note=getSlideNotes($slide); if($note){ print " - NOTES: $note\n"; } print "-"x40 . "\n"; next SLIDE; } $pres->Close(); ############ sub isNum{ my $str=shift; if(!length($str)){return 0;} if($str=~/^\-*?[0-9\.]+$/is){ #make sure there is only one decimal (125.265.21.23 is not a +number) my @parts=split(/\./,$str); if(scalar @parts < 3){return 1;} } return 0; } ############### sub getSlideNotes{ my $slide=shift || return ''; #Get the text for this slide my @slidenotes=(); my $notes=$slide->NotesPage; my $notes_cnt=$notes->Count; if($notes_cnt){ for my $note (in $notes){ #Does this note have shapes my $shapes=$note->Shapes; my $shapes_cnt=$shapes->Count; if($shapes_cnt){ for my $shape (in $shapes){ next unless $shape->HasTextFrame; my $pars=$shape->TextFrame->TextRange->Paragraphs +; my $pars_cnt=$pars->Count; if($pars_cnt){ for my $par (in $pars){ my $txt=$par->Text; $txt=~s/^[\s\t]+//s; $txt=~s/[\s\t]+$//s; if(length($txt) && !isNum($txt)){ push(@slidenotes,$txt); } } } else{ my $txt=$shape->TextFrame->TextRange->Text; $txt=~s/^[\s\t]+//s; $txt=~s/[\s\t]+$//s; if(length($txt) && !isNum($txt)){ push(@slidenotes,$txt); } } } } } } my $slidenotes_cnt=@slidenotes; if($slidenotes_cnt){ my $notes=join("\n",@slidenotes); return $notes; } return ''; }
In reply to Getting Slide Notes from PowerPoint files by slloyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |