Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Adding Slide to Powerpoint

by traveler (Parson)
on Feb 16, 2007 at 22:10 UTC ( #600532=note: print w/replies, xml ) Need Help??

in reply to Adding Slide to Powerpoint

foreach $slide (@slides){ $pres -> Slides($slideIndex) = $slides[$k]; +$slideIndex++; $k++};
Needs to be
foreach $slide (@slides){ $pres -> Slides->Add($slideIndex,$slides[$k] +->Layout) = $slides[$k]; $slideIndex++; $k++};
Untested, but it is close to an existing proggie I have.


Replies are listed 'Best First'.
Re^2: Adding Slide to Powerpoint
by ~~David~~ (Hermit) on Feb 16, 2007 at 23:07 UTC
    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++; } };
      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...
Re^2: Adding Slide to Powerpoint
by ~~David~~ (Hermit) on Feb 20, 2007 at 16:34 UTC
    Everyone, Thanks for your help. For reference, here is the working code...
    sub addMyFile{ my $file = shift; #this is the filename of the file i am adding my $fullpath = "$edmdir\\$file"; #full filename with path my $addpres = $ppt->Presentations->Open( $fullpath ) or die "Can't + open PowerPoint file '$fullpath': $!\n"; my @slides; my $j = 1; my $slide; while ($addpres->Slides($j)){$slides[$j] = $addpres->Slides($j);$j +++}; shift(@slides); #because I start at 1, i need to drop off the fir +st element. my $m; my $k = 0; foreach (@slides){ $m = $k+1; #because slide index starts at 1, not 0; $addpres->Slides($m)->Copy; #copy newly opened file slide... $pres->Slides->Paste($slideIndex); #past it into current pres +entation. $slideIndex++; $k++; } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://600532]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2018-10-22 04:24 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (119 votes). Check out past polls.