Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help - printing

Status
Not open for further replies.

NurseIS

MIS
Sep 3, 2001
46
US
Want to print a one page (form) where user clicks a cmd button and page prints to a specific network printer. Client side processing. (Just starting to explore Wsh)

Is it reasonable and clean to use the below to connect then disconnect the printer assignment?


Sub cmdBtn_OnClick
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.AddPrinterConnection "LPT1:", "\\Server\Print1"
WshNetwork.SetDefaultPrinter "\\Server\Print1"

'then print by code
window.print()

'then disconnect the added printer
WshNetwork.RemovePrinterConnection "LPT1:", "\\Server\Print1"
End Sub
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top