Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to make COPY of Worksheet(1) to some other Worksheet ???

Reply
Thread Tools

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

 
 
Katja
Guest
Posts: n/a
 
      01-12-2008
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;
------------------



 
Reply With Quote
 
 
 
 
andygpeters@gmail.com
Guest
Posts: n/a
 
      01-14-2008
On Jan 12, 9:09*pm, "Katja" <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Excel - Copy whole worksheet to a new weeksheet alxkhlee@gmail.com Computer Support 1 12-20-2007 03:42 PM
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
is dict.copy() a deep copy or a shallow copy Alex Python 2 09-05-2005 07:01 AM
How to Make a Printable Worksheet? JDP@Work ASP .Net Web Controls 0 10-16-2004 02:14 AM



Advertisments