venerable monk-folk,
i'm trying to fast-track an application that will require printing of forms. i'm pretty new to Win32 development ( native *nix by preference ) and am not sure where to go to find good info on OLE automation.
What i'm trying to do is open up an instance of InternetExplorer.Application, then use the Navigate method to a pre-defined location ( the location of the generated document to be printed ) and then open up the Print dialog. This would be more easily done using microsoft word, probably, but it is more likely to find IE on any given machine than Word and i'd like to stick to the lowest common denominator as much as possible.
Having created a new instance of InternetExplorer.Application, I browse through the tree of constants and find OLECMDID_PRINT == 6 .. i note that there is an ExecWB method that seems to be being used in other languages to do this very thing.
my question is, how do i properly invoke the command? .. my ( not working ) code so far :
use warnings;
use strict;
use Win32::OLE;
use Win32::OLE::Const;
{
my $IE = Win32::OLE->new( 'InternetExplorer.Application' );
my $ie_const = Win32::OLE::Const->Load( $IE );
$IE->Navigate( "C:\\tmp\\somefile.html" );
# at this point IE opens up and properly displays the page, but he
+re is where i get lost .. my best guess is -
$IE->ExecWB( ${ $ie_const }{ 'OLECMDID_PRINT'} } );
}
( very ) obviously i'm missing somthing, particularly with regards to ExecWB. I also tried to follow a direct ( supposedly working ) example of python using the same commands via :
$IE->ExecWB( ${ $ie_const }{ 'OLECMDID_PRINT' }, ${ $ie_const }{ 'O
+LECMDID_PROMPTUSER' } );
which results in an error of : "Trying to revoke a drop target that has not been registered". Looking in to this error shows that its possible that the browser may not be ready. The suggested method was to use the QueryStatusWB method until it returned OLECMDF_SUPPORTED + OLECMDF_ENABLED ( which should be a total of 3 ) .. putting this code in to a loop which queries the status continues to return 0 well after the page has loaded.
I've read through the Activestate documentation on OLE and their examples are pretty good so long as you have the Office suite installed ;) .. what i'm really after is how to execute arbitrary commands available via the constants defined by a given instance of an OLE object. My suspicion ( loosely founded ) is that $IE in the above case is not the object i need to be dealing with - possibly i need to create another object derived from $IE, such as :
my $automater = $IE->Automation()
or something along those lines?
any help / pointers Greatly appreciated!