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

hi monks... i want to add a pie chart on the powerpoint slide through the perl, i am able to do the same for Excel but i want the pie chart on a pertiucular slide on a powerpoint file...please help. the data for the pie chart will be passed throught an array from the perl code.

Replies are listed 'Best First'.
Re: pie chart in powerpoint
by hdb (Monsignor) on Apr 18, 2013 at 14:34 UTC

    Now cleaned up:

    use strict; use Win32; use Win32::OLE; use Win32::OLE::Const 'Microsoft PowerPoint'; use Win32::OLE::Const 'Microsoft Excel'; my $ex; eval {$ex = Win32::OLE->GetActiveObject('Powerpoint.Application')}; unless (defined $ex) { $ex = Win32::OLE->new('Powerpoint.Application' ) or die "Oops, cannot start PPT\n"; } $ex->{'Active'} = 1; $ex->{'Visible'} = 1; $ex->Presentations->Add(); my $Presentation = $ex->ActivePresentation; my $Slide = $Presentation->Slides->Add({Index=>1, Layout=>ppLayoutTitl +eOnly}); $Slide->{Name} = "Slide111112"; my $Title=$Slide->Shapes->{Title}; $Title->TextFrame->TextRange->{Text} ="Weekly Analysis - Closing Balan +ce"; my $chart = $Slide->Shapes->AddOLEObject( 50, 50, 500, 500, "MSGraph.C +hart" ); my $graph = $chart->OLEFormat->Object; my $datasheet = $graph->Application->DataSheet; $graph->{'HasLegend'} = 0; $graph->{'ChartType'} = xl3DPie; for( my $row=2; $row<=5; $row++ ) { for( my $col=2; $col<=2; $col++ ) { $datasheet->Cells($row,$col)->{'Value'} = rand(); } } $datasheet->Application->Update;
      hey...thanx a lot...that really wrokd well for me as expected....Thank You Monk.
Re: pie chart in powerpoint
by Anonymous Monk on Apr 18, 2013 at 12:22 UTC
      hey...thats all about excel...i need it for powerpoint.

        hey...thats all about excel...i need it for powerpoint.

        They're one and the same, the documentation is on MSDN, you use Win32::OLE and the tips and tricks

Re: pie chart in powerpoint
by hdb (Monsignor) on Apr 18, 2013 at 12:46 UTC

    Have a look at my scratchpad hdb's scratchpad. You might find some of what you need. Also look at commented lines.

    UPDATE: See condensed and cleaned version below.