How to make COPY of Worksheet(1) to some other Worksheet ???

K

Katja

How to make COPY of Worksheet(1)to some other Worksheet ???

Please Help!


------------------
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Open('d:\cgi\work.xls');
my $Sheet = $Book->Worksheets(1);

# How to make COPY of Worksheet(1) to some other Worksheet ???
#

$Book->Save;
------------------
 
A

andygpeters

How to make COPY of Worksheet(1)to some other Worksheet ???

Please Help!

------------------
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Open('d:\cgi\work.xls');
my $Sheet = $Book->Worksheets(1);

# How to make COPY of Worksheet(1) to some other Worksheet ???
#

$Book->Save;
------------------

I normally record a macro and use what's been generated.
In your case this gives

Sheets("Sheet1").Select
Sheets("Sheet1").Copy Before:=Sheets(2)

Which translates to something like

$Sheet->Select;
$Sheet->Copy( 'Before' => $Book->Worksheets(2));

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top