I've had a request to create a program that reviews a DB of values that can be converted into URL requests - then proceed to the URL and print the first page of the HTML document (as presented, not with markup). I've gotten the code to print normally - but I don't want to be singly responsible for razing the rain forest just to get the first page of the website (not to mention the $$$ cost of that waste...). A sample of the code is below:
use strict; use Getopt::Long; use Win32::OLE qw( EVENTS with in ); use Win32::OLE::Variant; use Win32::OLE::Enum; ###################################################################### +########## # Enumerated IE Values ###################################################################### +########## use constant OLECMDID_PRINT => 6; use constant OLECMDID_SAVE => 3; use constant OLECMDID_SAVEAS => 4; use constant OLECMDID_OPEN => 1; use constant OLECMDEXECOPT_DEFAULT => 0; use constant OLECMDEXECOPT_PROMPTUSER => 1; use constant OLECMDEXECOPT_DONTPROMPTUSER => 2; ###################################################################### +########## # Option Variable Declaration ###################################################################### +########## my %args; ###################################################################### +########## # Process Command Line Options ###################################################################### +########## GetOptions( \%args, "help!" => sub { f_usage() }, ); ###################################################################### +########## # Global Variable Declaration and Setting ###################################################################### +########## my $Application = "InternetExplorer.Application"; $| = 1; ###################################################################### +########## # Function Declaration ###################################################################### +########## sub f_usage { print "Usage: " . __FILE__ . "\n"; exit 0; } ###################################################################### +########## # Main Process ###################################################################### +########## my $IE = Win32::OLE->new( $Application ) || die "$0: Could not start: $Application - $@, $!\n"; $IE->{Visible} = 1; while ( <DATA> ) { chomp; $IE->Navigate( $_ ); while ( $IE->Busy() ) { sleep 2; } $IE->ExecWB( OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER ); sleep 5; while ( $IE->Busy() ) { sleep 2; } } $IE->Quit(); exit; __DATA__ my.yahoo.com
This is the version that prints all pages (rainforest not-so-friendly). Again - I want to know how to default this to just 1 page. Any and all help appreciated. -Michael

In reply to Controlling IE Printing from a Win32::OLE object by berntsmr

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.