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
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