Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: need program to hang out awhile?

by tokpela (Chaplain)
on Dec 03, 2009 at 10:01 UTC ( #810793=note: print w/ replies, xml ) Need Help??


in reply to need program to hang out awhile?

Use Win32::OLE to control Excel and print from within Excel.

I used the code below several years ago to print out an Excel sheet every day. Please note - this code is a snippet and is untested as is.

Hopefully, you can get the idea and adapt to your situation.

use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', + 'Quit'); my $book = $excel->Workbooks->Open("I:\\Path\\To\\File\\file +.xls"); my $sheet = $excel->Worksheets(1); #Sub PrintOut([From], [To], [Copies], [Preview], [ActivePrinter], [Pri +ntToFile], [Collate]) $sheet->PrintOut(1,1,1,0,"HP LaserJet IIIP",0,0); $book->Save; $book->Close; print "Done\n";


Comment on Re: need program to hang out awhile?
Download Code
Replies are listed 'Best First'.
Re^2: need program to hang out awhile?
by cypress (Beadle) on Dec 03, 2009 at 14:22 UTC

    Hi,

    OLE might be a promising trail to follow, but unfortunately I'm on a Mac for this project.

    For a related Windows project, however, I'd like to see your PrintOut sub definition in full.

    Continued thanks,

    cypress

      The PrintOut() method is defined somewhere inside MS Excel :-)

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://810793]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2015-07-28 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls