gpt4 book ai didi

perl - 使用 Perl 的密码保护 PPT 文件

转载 作者:行者123 更新时间:2023-12-04 11:52:56 24 4
gpt4 key购买 nike

有人可以让我知道如何在 Perl 中使用下面的 Microsoft Presentation Object Properties 吗?

http://msdn.microsoft.com/en-us/library/office/bb251459(v=office.12).aspx

基本上我想使用 Password 属性来保护演示文稿。

最佳答案

该脚本基于来自 angiehope 的 perlmonks 文章根据上面@FtLie 的评论。我已经用 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();

关于perl - 使用 Perl 的密码保护 PPT 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16853067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com