Perl 打开 word 文档并修改内容的代码

发布时间:2019-10-09编辑:脚本学堂
Perl打开word文档并修改内容的代码

Perl打开word文档并修改内容的代码

复制代码 代码如下:

#!/usr/bin/perl

use warnings;
use strict;
use Win32::OLE;

chomp( my $line = <STDIN> );

my $word = new Win32::OLE( "Word.Application" )
   or die( "Error opening a document in Word: $!" );

$word->{ Visible } = 1;
$word->Documents->Add();
$word->Selection->Font->{ Size } = 100;
$word->Selection->Font->{ SmallCaps } = 1;
$word->Selection->Font->{ Animation } = 3;   # sparkle text
$word->Selection->TypeText( $line );