http://www.perlmonks.org?node_id=995522

kalyanbhave has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am Not able to attach and edit Excel file , which helps us to send an email automatically to the end users with excel attachment..

#!/usr/bin/perl -w use strict; use warnings; use OLE; use Win32::OLE::Const 'Microsoft Excel'; my $Excel = CreateObject OLE "Excel.Application"; my $Book2 = $Excel->Workbooks->Add(); my $Book3 = $Excel->Workbooks->Open("xxx.xls"); my $Sheet3 = $Book3->Worksheets(1); $Sheet3->Select; $Sheet3->Move("Before" => $Book2->Worksheets(1)); $Book3->Close(0); $Book2->SaveAs({Filename =>"yyy.xls",FileFormat => xlOpenXMLWorkbookMa +croEnabled}); $Book2->Close(); $Excel -> Quit();

Error:- Unrecognized escape \D passed through at eight.pl line 9. Unrecognized escape \D passed through at eight.pl line 14. Can't call method "Worksheets" on an undefined value at eight.pl line 10.

I have downloaded the module Win32-OLE-0.1709.tar.gz , but I am not aware how to proceed it further..
  • Comment on Not able to attach and edit Excel file , which helps us to send an email automatically to the end users with attachment..
  • Download Code

Replies are listed 'Best First'.
Re: Not able to attach and edit Excel file , which helps us to send an email automatically to the end users with attachment..
by nemesdani (Friar) on Sep 25, 2012 at 12:33 UTC
    I'm not sure you succeed in opening the xxx.xls in the first place. Try an absolute path instead e.g. "D:\\Work\\Test\\xxx.xls"


    I'm too lazy to be proud of being impatient.