473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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
Nov 22 '05 #1
0 1037

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are...
0
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are...
9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
0
by: DotNetDummy | last post by:
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...
5
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of...
4
by: Suzanka | last post by:
Hello, I have an application written in C# on visual studio .NET. It is a web aplication. The application consists of many different forms, that users occassionaly want to print out for filing....
0
by: Nigel | last post by:
I successfully create a .NET Component (Visual Basic .NET) that would print, unfortunately when used within a web browser it appears that .NET security doesn't allow you to run code that interacts...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.