By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

How to set printing setting on a default when calling I.E browser object for printing

P: n/a
Hi all,

I am trying to set the printing setting e.g duplex mode etc. on a
default printer when I.E object started printing a particular html
doc.

Here's the partial code, any help would be appreciated.

I have been using system.drawing.printing method but not much help
since drawing.printing required printDocument() object which specially
for text file but in my case I needed the I.E object for printing html
along with css and javascript.

'Set the Default printer --------------------------
Dim wshnetwork As Object

wshnetwork = CreateObject("WScript.Network")
wshnetwork.SetDefaultPrinter(printerValue)
'---------------------------------------------------

IEprintFile(grab_HTML, grab_JS, printerValue)

Public Sub IEprintFile(ByVal HTMLFILE As String, ByVal JSFILE
As String, ByVal PrinterName As String)

Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Dim IE As SHDocVw.InternetExplorer

IE = New SHDocVw.InternetExplorer

IE.Visible = False
IE.Navigate(System.Windows.Forms.Application.Start upPath &
"\process\" & HTMLFILE)

While Not IE.ReadyState =
SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
End While
IE.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER)
Dim TotalFileSize =
FileLen(System.Windows.Forms.Application.StartupPa th & "\process\" &
HTMLFILE) + FileLen(System.Windows.Forms.Application.StartupPa th &
"\process\" & JSFILE)

Select Case (TotalFileSize)
Case Is < 45000
System.Threading.Thread.Sleep(2000)
IE.Quit()
Case Is < 90000
System.Threading.Thread.Sleep(4000)
IE.Quit()
Case Is > 90000
System.Threading.Thread.Sleep(6000)
IE.Quit()
End Select
'File.Delete(System.Windows.Forms.Application.Star tupPath &
"\process\" & JSFILE)
'File.Delete(System.Windows.Forms.Application.Star tupPath &
"\process\" & HTMLFILE)

Kill(System.Windows.Forms.Application.StartupPath &
"\process\" & HTMLFILE)
Kill(System.Windows.Forms.Application.StartupPath &
"\process\" & JSFILE)

End Sub
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.