이 스크립트는 위의 @FtLie의 설명에 따라 angiehope의 perlmonks 기사를 기반으로합니다. 필자는 Office 2010에서이를 테스트했습니다. 스크립트는 스크립트와 동일한 파일에 ppt_test.ppt라는 파일을 만들고 저장된 문서에 암호 'secret'을 설정합니다.
use strict;
use warnings;
use v5.10;
use Try::Tiny;
use Data::Dumper;
use Carp;
use FindBin qw ($Bin);
use Win32::OLE qw(in CP_UTF8);
Win32::OLE->Option(CP => CP_UTF8);
$Win32::OLE::Warn = 3;
my $filename = "$Bin/ppt_test.ppt";
unlink $filename if (-e $filename);
print("Starting Powerpoint Object\n");
my $power = Win32::OLE->GetActiveObject('Powerpoint.Application') ||
Win32::OLE->new('Powerpoint.Application', 'Quit');
my $ppt = $power->Presentations->Add();
# 12 = blank layout
my $slide = $ppt->Slides->Add(1,12);
# 1 = text in horizontal direction, the next two numbers describe the position
# and the last numbers the width and height of the box
my $new_textbox = $slide->Shapes->AddTextbox(1,30,30,600,200);
my $text_frame = $new_textbox->TextFrame;
my $text_range = $text_frame->TextRange;
$text_range->{Text} = "Please print \x{03B1},\x{03B2},\x{03B3}";
# Now set the password
my $password = 'secret';
$ppt->{Password} = $password;
$ppt->SaveAs($filename);
$ppt->Close();
일반적으로 할 수 없습니다. ppt 파일은 매우 독점적이며 Perl에서이 파일에 액세스하는 모듈을 모릅니다. PowerPoint를 동일한 컴퓨터에 설치 한 경우 Win32 :: Ole을 사용하여 Perl에서 PowerPoint를 자동화 할 수 있습니다 (예 : 몇 가지 힌트를 보려면 http://www.perlmonks.org/?node_id=922835를 참조하십시오) – FtLie