in reply to VBA to Perl
use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; use Cwd; my ($file) = @ARGV; my $cwd_path = getcwd(); $cwd_path=~ s/\//\\/gs; my $file_name = "$cwd_path\\$file"; my $Word = Win32::OLE->new('Word.Application'); $Word->{'Visible'} = 1; my $document = $Word->Documents->Open($file_name) || die("Unable to op +en document", Win32::OLE->LastError()); my $Selection = $Word->Selection; $Selection->HomeKey (wdStory); $Selection->TypeText("This is the inserted text"); $Selection->Collapse (wdCollapseEnd); $Selection->TypeParagraph; $Selection->TypeText("This is the inserted text 2"); $Selection->Collapse (wdCollapseEnd); $Selection->TypeParagraph; $Word->Documents($file_name)->Save(); $Word->Quit();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: VBA to Perl
by Samy_rio (Vicar) on Mar 10, 2006 at 09:56 UTC | |
by marto (Cardinal) on Mar 10, 2006 at 10:16 UTC | |
by wfsp (Abbot) on Mar 10, 2006 at 10:17 UTC |