Link to home
Start Free TrialLog in
Avatar of NEILPH
NEILPHFlag for New Zealand

asked on

print unopened html file

I've saved an html page from the internet onto my PC and want to print the rendered content without opening it.

What I want to happen is for the Internet Explorer 8 Print Dialog box to automatically appear so I can manually get it to print, in the same way as if I had selected the file in Windows Explorer and chosen Print on the "right-click mini menu."

You'll see from my code snippet that I have found a suggested solution elsewhere but it doesn't do anything when I click the doprint.vbs from Windows Explorer.


SUGGESTED DOPRINT.VBS WAY TO PRINT UNOPENED HTML FILE. NOTHING HAPPENS?

surl="mypage.html"    'your input

dim bpttd_ready, istatus
set oie=wscript.createobject("internetexplorer.application","ie_")
do while oie.readystate<>4 : wscript.sleep 50 : loop
on error resume next
istatus=oie.querystatuswb(6)
if err.number<>0 then    
    wscript.echo "Cannot find the printer. Operation aborted."
    oie.quit
    set oie=nothing
    wscript.quit err.number
end if
on error goto 0
oie.navigate surl
do while oie.readystate<>4 : 
wscript.sleep 50 : loop
bpttd_ready=false
oie.execwb 6,2
do while not bpttd_ready : wscript.sleep 50 : loop
oie.quit
set oie=nothing
wscript.quit

sub ie_PrintTemplateTeardown(pDisp)
    bpttd_ready=true    'global bpttd_ready; no dim here
end sub

Open in new window

Avatar of Jackie Man
Jackie Man
Flag of Hong Kong image

What is your OS?
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, ShellExecute() should work perfectly.
Avatar of NEILPH

ASKER

Brilliant.

It worked a treat.

Incidentally, I'm using VFP 9.0 SP2 in Windows Vista.