-------8<-----------
I've been using Perl for a number of years,
-------8<-----------
And you post code with no use strict and warnings? :p
Actually what you posted fails to run. So I tidied it up a bit and got
this to copy and paste as you desired. Do allow for line wrap.
<CODE>
use strict;
use warnings;
# Don't need these, but good to load as your code gets bigger
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Variant;
$Win32::OLE::Warn = 3;
my $Excel_CSAA_Test_Retrieve = 'C:\Temp\Temp.xls';
my $excel_app = Win32::OLE->new('Excel.Application')
or die "could not create excel app\n";
$excel_app->{'Visible'} = 1;
$excel_app->{ 'SheetsInNewWorkbook' } = 1;
my $excel_Workbook =
$excel_app->Workbooks->Open($Excel_CSAA_Test_Retrieve ) or die "could
not open $Excel_CSAA_Test_Retrieve:- $! \n";
my $Sheet1 = $excel_Workbook->Worksheets(1);
# I dont have your VBA function
# In your posting you declared $excel_Workbook before the next variable
declaration so I got an error
# I also got errors about unterminated lines
# Bottom line is your code as posted does not run with strict and
warnings enabled
foreach my $Col('A' .. 'Q')
{
foreach my $Row(1 .. 40)
{
$Sheet1->Range("$Col$Row")->{Value} = int(rand($Row));
}
}
$Sheet1->Range("A29:P39")->Select();
$Sheet1->Range("A29:P39")->Copy();
my $Sheet =
$excel_Workbook->Worksheets->Add({After=>$excel_Workbook->Worksheets($ex
cel_Workbook->Worksheets->{Count})}) or die Win32::OLE->LastError();
$Sheet->{Name} = "Glens";
my $GlensSheet = $excel_Workbook->Worksheets("Glens");
$GlensSheet->Range("A29")->Select();
$GlensSheet->Paste()
</CODE>
Cheers,
Just in
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs