Hello Experts
I have a webform that I need to print with a one click solution without the use of the client's print dialog box. On my webform the user submits the page and some info is stored in a database. After that I redirect them to another webform with the same info they submitted without the buttons and drop down lists etc. On page load this page will print the actual label.
When that page loads I'd like to have it print to a named printer (not default printer) without them having to use the normal print dialog box. I see some code examples out there but I want to know the best/easiest way to accomplish this. We plan on installing a printer on the client's machine that will use this web app. We will name the printer something specific "mycompanynameprinter". How do I avoid the print dialog box?
Here's the code I have so far:
Dim strComputer, strOldDefault As String
Dim objWMIService, objPrinter, Wscript, WBControl As Object
Dim colPrinters As Object
strComputer = "."
objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
colPrinters = objWMIService.ExecQuery("S
elect * from Win32_Printer Where Default = TRUE")
For Each objPrinter In colPrinters
strOldDefault = objPrinter.Name
strOldDefault = Replace(strOldDefault, "\", "\\")
Next
colPrinters = objWMIService.ExecQuery("S
elect * from Win32_Printer Where Name = 'DYMO'")
For Each objPrinter In colPrinters
objPrinter.SetDefaultPrint
er()
Next
'Wscript.Sleep(2000)
WBControl.ExecWB(6, 2, 3)
colPrinters = objWMIService.ExecQuery("S
elect * from Win32_Printer Where Name = '" & strOldDefault & "'")
For Each objPrinter In colPrinters
objPrinter.SetDefaultPrint
er(strOldD
efault)
Next
This code comes from another question I asked:
http://www.experts-exchange.com/Programming/Languages/.NET/Q_23491529.htmlI'm not sure how to actually get the label to print. What is Wscript & WBControl? I referenced them incorrectly and am not sure how to get those to work. I also need control over the page layout of the label like portrait/landscape and the paper source. This is a dymo label printer so I need to set it to a "shipping" label. Ideas?
Start Free Trial