use Win32::OLE 'EVENTS'; use File::Spec::Functions; use File::Basename; $Win32::OLE::Warn = 3; $URL = "http://www.weather.com"; my $IE = Win32::OLE->new("InternetExplorer.Application") || die "Could not start Internet Explorer\n"; $IE->{Addressbar} = 1; $IE->{Menubar} = 1; $IE->{Toolbar} = 1; $IE->{Statusbar} = 1; $IE->{Width} = 800; $IE->{Height} = 700; $IE->{Top} = 0; $IE->{Left} = 0; $IE->{Resizable} = 1; $IE->{visible} = 1; # Navigate to desired URL $IE->Navigate($URL); while ($IE->{Busy}) { Win32::Sleep 500; Win32::OLE->SpinMessageLoop(); } $Contents = $IE->{DOCUMENT}; $Target = "g:\\zbuzz\\Weather.mht"; # # remove any prior file # $path = $Target; (my $filename = $path) =~ s/^.*[\\\/]//; # get just the filename po +rtion of path print "file=$filename\n"; $Targetdir= dirname($path); $currdir = Win32::GetCwd(); print "Current Working Directory=$currdir\n"; print "Targetdir=$Targetdir\n"; chdir ($Targetdir); $path = $Targetdir . "\\" . $filename; ($name, $dir, $ext ) = fileparse ($path, '\..*' ); print "name=$name, dir=$dir, ext=$ext \n"; $base = basename($path); $dir= dirname($path); print "dir=$dir, base=$base\n" ; # # changes the location of the saved file to the desired drive and dire +ctory # $newdir = chdir ( $dir); Win32::SetCwd($newdir); # moves the file save to g:\zbuzz unlink ( $Target ); # # Save the MHT file using ExecWB # my $OLECMDID_SAVEAS = '4'; my $OLECMDEXECOPT_PROMPTUSER = '0'; my $OLECMDEXECOPT_DONTPROMPTUSER = '1'; # prompts for the Save As +dialog # 4 - 1 combination produces Save Webpage ( so you can save as MHT ) # 4 - 1 combination populates file name as Window Title # 4 - 1 combination does not save the file in the desired directory; # 4 - 1 comination => have to manually change the directory to the des +ired location # # ExecWB does pull up the Save As HTML dialog box, however, Don't Prom +pt User does not work # $IE->ExecWB('4', '1', $Contents, $Target ); $IE->Quit(); exit; P.S., Where do I find the various constants to incorporate such as OLE +CMDEXECOPT_DONTPROMPTUSER, etc.
In reply to Perl - ExecWB - SaveAs No Prompts by Ad Aspera
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |