使用Perl密码保护的PPT文件
发布时间:2020-12-15 23:32:46 所属栏目:大数据 来源:网络整理
导读:有人可以让我知道如何在Perl中使用下面的Microsoft演示文稿对象属性? http://msdn.microsoft.com/en-us/library/office/bb251459(v=office.12).aspx 基本上我想使用Password属性来保护演示文稿. 解决方法 根据@FtLie上面的评论,此脚本基于 angiehope的perlm
有人可以让我知道如何在Perl中使用下面的Microsoft演示文稿对象属性?
http://msdn.microsoft.com/en-us/library/office/bb251459(v=office.12).aspx 基本上我想使用Password属性来保护演示文稿. 解决方法
根据@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 Objectn" ); 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,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(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |