Code: [show] | [select all]
use warnings;
use Encode;
use utf8;
use strict;
use Cwd;
my $fold = getcwd();
$fold=~s/\//\\/;
use Win32::OLE;
use Win32::OLE::Const ('Microsoft Word');
use Win32::OLE::Variant;
our $shape;
my $word = CreateObject Win32::OLE 'Word.Application' or die $!;
$word->{'Visible'} = 0;
my $document = $word->Documents->Open($fold ."\\untitle.docx");
my $selection = $word->Selection;
$selection -> TypeText(encode('gbk',"大家好"));
$selection -> TypeParagraph;
$selection -> TypeText("How do you feel today");
$selection -> TypeParagraph;
&line(1,1,100,100,1);
#$document->Save();
$word->quit();
sub line {
my ($x1, $y1, $x2, $y2, $color) = @_;
my $msoArrowheadTriangle = 2;
$shape=$document->Shapes->Addline(
$x1, $y1, $x2, $y2
);
$shape->Line->ForeColor->{'SchemeColor'}=$color;
$shape->Line->{'EndArrowheadStyle'}=$msoArrowheadTriangle;
my $test;
$test = $shape=$document->Shapes->AddConnector(
2, 194.4, 141.6, 183, 80.4);
$test = $shape=$document->Shapes->BuildFreeform(
0, 180.9, 226.55);
$test->AddNodes(1, 0, 227.4, 269.55);
$test->AddNodes(1, 0, 114.15, 359.1);
$test->ConvertToShape->{'Select'};
}