use Win32::OLE; use Win32::OLE::Const 'Microsoft Office'; use Win32::OLE::Const 'Microsoft PowerPoint'; use strict; #### $Win32::OLE::Warn = 3; # die on errors #### my $filename = "c:\\temp\\testpower.ppt"; #### print( "Starting Powerpoint Object\n" ); my $power = Win32::OLE->GetActiveObject('Powerpoint.Application') || Win32::OLE->new('Powerpoint.Application', 'Quit'); #### print( "Creating a presentation\n" ); my $ppt = $power->Presentations->Add(); $ppt->SaveAs($filename); #### print( "Creating a slide\n" ); my $slide = $ppt->Slides->Add(1, ppLayoutBlank); $ppt->SaveAs($filename); #### my $pname = 'C:\WINNT\Web\Wallpaper\Fall Memories.jpg'; my $shape = $slide->Shapes->AddPicture( $pname, msoFalse, msoTrue, 20, 1 ); # scale to 50% of original size $shape->ScaleHeight( 0.5, msoTrue, msoScaleFromTopLeft ); $shape->ScaleWidth( 0.5, msoTrue, msoScaleFromTopLeft ); $ppt->SaveAs($filename); #### print( "Adding a 4 wide by 3 high table\n" ); my $table = $slide->Shapes->AddTable( 3, 4, 1, 100 ); my $columns = $table->Table->Columns->Count; my $rows = $table->Table->Rows->Count; for ( my $row = 0; $row < $rows; $row++ ) { for ( my $col = 0; $col < $columns; $col++ ) { my $cell = $table->Table->Rows($row+1)->Cells($col+1); my $textframe = $cell->Shape->TextFrame; $textframe->TextRange->{Text} = "$col,$row"; $textframe->TextRange->Font->{Bold} = msoFalse; $textframe->TextRange->Font->{Name} = "Arial"; # set text size AFTER changing text $textframe->TextRange->Font->{Size} = "12"; } } $ppt->SaveAs($filename);