sanPerl has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I am Not good in VBA, and I would like to convert a VBA Macro to Perl. After reading few help pages from ActivePerl site. I wrote a Perl code. Now it is giving following error
Can't modify non-lvalue subroutine call at rapid.pl line 16.
My VBA Macro goes as follows
VBA Macro
Perl Script
Regards,
Sandeep
Update
Dear All,
Thanks to all for your support. It was my lack of knowledge that I was using "Text" instead of "TypeText". Thanks to marto for providing this hint.
I am Not good in VBA, and I would like to convert a VBA Macro to Perl. After reading few help pages from ActivePerl site. I wrote a Perl code. Now it is giving following error
Can't modify non-lvalue subroutine call at rapid.pl line 16.
My VBA Macro goes as follows
VBA Macro
and my Perl script goes as follows.Selection.HomeKey wdStory Selection.Text = "This is the inserted text 1" Selection.Collapse wdCollapseEnd Selection.TypeParagraph Selection.Text = "This is the inserted text 2" Selection.Collapse wdCollapseEnd Selection.TypeParagraph
Perl Script
I searched from 'SuperSearch' but could Not receive satisfactory information. I would be grateful, if somebody could guide me on this. I don't expect straightforward solutions but if you could direct me to any good tutorials on this topic, I would be grateful to you.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; $Word->Documents->Open($file_name) || die("Unable to open document", W +in32::OLE->LastError());; $Word->Selection->HomeKey (wdStory); $Word->Selection->Text="This is the inserted text"; $Word->Selection->Collapse (wdCollapseEnd); $Word->Selection->TypeParagraph; $Word->Selection->Text("This is the inserted text 2"); $Word->Selection->Collapse (wdCollapseEnd); $Word->Selection->TypeParagraph; $Word->Documents($file_name)->Save(); $Word->Quit();
Regards,
Sandeep
Update
Dear All,
Thanks to all for your support. It was my lack of knowledge that I was using "Text" instead of "TypeText". Thanks to marto for providing this hint.
Back to
Seekers of Perl Wisdom