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

Discussion in 'Perl Misc' started by Katja, Jan 12, 2008.

  1. Katja

    Katja Guest

    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;
    ------------------
     
    Katja, Jan 12, 2008
    #1
    1. Advertising

  2. Katja

    Guest

    On Jan 12, 9:09 pm, "Katja" <> 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.
     
    , Jan 14, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Holmes!
    Replies:
    2
    Views:
    436
    Malcolm Dew-Jones
    Apr 2, 2005
  2. Alex
    Replies:
    2
    Views:
    1,238
  3. Replies:
    26
    Views:
    2,123
    Roland Pibinger
    Sep 1, 2006
  4. sberry
    Replies:
    1
    Views:
    298
    sberry
    Dec 13, 2007
  5. JDP@Work

    How to Make a Printable Worksheet?

    JDP@Work, Oct 16, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    112
    JDP@Work
    Oct 16, 2004
Loading...

Share This Page