#!perl use strict; use warnings; use Cwd; use Win32::OLE; use Win32::OLE::Const 'Microsoft PowerPoint'; $Win32::OLE::Warn = 3; my $file = "PM30306901A SMP Limit Switch.pptx"; my $dir = getcwd(); my $filename = $dir . '\\' . $file; print ("Starting PowerPoint\n"); my $process = Win32::OLE->GetActiveObject('Powerpoint.Application') || Win32::OLE->new('Powerpoint.Application', 'Quit'); print ( "Opening '$filename'\n" ); my $ppt = $process->Presentations->Open($filename); #my $pp = Win32::PowerPoint->new; $file =~ s/PM3/TCF6203/; $filename = "$dir/$file"; my @activeslides = $process->ActivePresentation->Slides->in; foreach my $slide (@activeslides) { my $name = $slide->{Name}; foreach my $shape ($slide->Shapes->in){ if ($shape->TextFrame->HasText){ if ($shape->HasTextFrame){ my $text = $shape->TextFrame->TextRange->Text; print "$name Text $text = "; if ($text eq "PM3"){ $shape->TextFrame->TextRange->{Text}= "TCF6203"; print "TCF6203\n"; } else { print "No change\n"; }; } } } } print ( "Saving '$filename'\n" ); $ppt->SaveAs($filename);