Thank you CountZero!

The following --portion of script-- is copying from one sheet and pasting to another to prepare for print. Everything works beautifully except for the line "$Excel->Application->CutCopyMode = False;".

I have tried writing the line several different ways and I have searched google and multiple other sights for ideas.

Opening of script is:

use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use warnings; #Content-Type: text/html; $Win32::OLE::Warn = 3; # die on errors... # get already active Excel application or open new $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # open Excel file $Book = $Excel->Workbooks->Open("c:/users/david/desktop/RBLCopy.xls");
The following is the portion of script containing the line in question.
# print routine ################ print "\nPrint (y/n) "; chomp($input = <STDIN>); if ($input eq 'y') { $lSheet = $Book->Worksheets("Location"); $iSheet = $Book->Worksheets("Input"); $oSheet = $Book->Worksheets("Output"); # Clear Input screen $iSheet->Activate(); if ($iSheet->Range("C4")->{Value} ne '') { $iSheet->Range("C4:J10000")->ClearContents(); } # Move Location data to Input Screen $lSheet->Activate(); $lSheet->Range("A5:A10000")->Copy(); $iSheet->Activate(); $iSheet->Range("C4")->Select(); $iSheet->Paste(); $lSheet->Activate(); $lSheet->Range("L5:L10000")->Copy(); $iSheet->Activate(); $iSheet->Range("D4")->Select(); $iSheet->Paste(); $lSheet->Activate(); $lSheet->Range("E5:J10000")->Copy(); $iSheet->Activate(); $iSheet->Range("E4")->Select(); $iSheet->Paste(); $iSheet->Range("A1")->Select(); $lSheet->Activate(); $Excel->Application->CutCopyMode = False; $lSheet->Range("A1")->Select(); print "\nAre you ready to print? (y/n)"; chomp($input = <STDIN>); if ($input eq 'y') { # print page 1 $oSheet->Activate(); $Excel->ActiveWindow->SelectedSheets->Printout(); # print page 2 $iSheet->Activate(); if ($iSheet->Range('C34')->{Value} ne '') { $iSheet->Range("C34:K63")->Copy(); $iSheet->Range("C4")->Select(); $iSheet->Paste(); $oSheets->Activate(); $oSheets->Range("K1")->Select(); $Excel->ActiveWindow->SelectedSheets->Printout(); } # print page 3 $iSheet->Activate(); if ($iSheet->Range('C64')->{Value} ne '') { $iSheet->Range("C64:K93")->Copy(); $iSheet->Range("C4")->Select(); $iSheet->Paste(); $oSheets->Activate(); $oSheets->Range("K1")->Select(); $Excel->ActiveWindow->SelectedSheets->Printout(); } } }
Thank you in advance for any help you can give.

david


In reply to Re^2: coding for excel in perl by ruxer
in thread coding for excel in perl by ruxer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.