in reply to Re: Adding Slide to Powerpoint
in thread Adding Slide to Powerpoint

Thanks for your suggestions, but I am still having problems. I see what you were trying to accomplish, so it has given me a better starting point. I updated the code, but it still fails with the same error. Do you know if I need to switch between active presentations in order to copy, paste, etc...
sub addMyFile{ my $file = shift; my $fullpath = "$edmdir\\$file"; my $addpres = $ppt->Presentations->Open( $fullpath ) or die "Can't + open PowerPoint file '$fullpath': $!\n"; my $j = 1; my $slide; my $newslide; while ($j < 10){ # this is hard coded while i figure out the bug +s, but it will be length of the file $newslide = $pres -> Slides->Add($slideIndex,$addpres->Slides( +$j)->Layout); $newslide = $addpres->Slides($j); $j++; $slideIndex++; } };

Replies are listed 'Best First'.
Re^3: Adding Slide to Powerpoint
by traveler (Parson) on Feb 16, 2007 at 23:43 UTC
    You do not need to switch presentations: using the proper var does that. Your old logic (with my changes) was better. Exactly what line gave the error on my version? Oh, and print out $k and $slideindex to be sure they are right and to figure when the error occurs.
      $pres -> Slides->Add($slideIndex,ppLayoutTitleOnly) = $slide; line gives the error "Can't modify non-lvalue subroutine call". If I remove the equals part, and try to add it to the next line, I get the right number of pages, but they are blank...
        My Bad. Your $slides are just pointers to ppt slides. Try
        my @slides; my $j = 1; my $slide; while ($addpres->Slides($j)){$slides[$j] = $addpres->Slides($j);$j +++}; my $k = 1; foreach $slide (@slides){ # make a new slide my $s = $pres -> Slides->Add($slideIndex,$slides[$k]->Layout) $slides[$k]->Copy; #get what you want $s->Paste; #save it $slideIndex++; $k++; }
        I always forget the details of the PPT DOM details.