R
Rick
Can anyone tell me how to set the printer using the process class in VB.net,
I've tried everything, it always goes to the default printer.
My Code:
Dim pathToExecutable As String = "WINWORD.EXE"
Dim SPrinter = \\PrinterPath\PrinterName 'Name Of printer
Dim sReport = "C:\WordDoc1.doc" 'Complete name/path of PDF file
Dim starter As New ProcessStartInfo(pathToExecutable, "/t " + sReport + " "
+ SPrinter + "")
Try
Dim MyProcess As New Process
'MyProcess.StartInfo.Arguments = "/t " + sReport + " " + SPrinter + ""
MyProcess.StartInfo.CreateNoWindow = False
MyProcess.StartInfo.Verb = "print"
MyProcess.StartInfo.FileName = sReport
'MyProcess.StartInfo = starter
MyProcess.Start()
Dim iloop As Int16 = 0
If MyProcess.HasExited = False Then
'if not then loop for 100 time to try and close the process'with 10 seconds
delay
While Not MyProcess.HasExited
System.Threading.Thread.Sleep(10000)
MyProcess.CloseMainWindow()
iloop = CShort(iloop + 1)
If iloop >= 100 Then
Exit While
End If
End While
End If
MyProcess.WaitForExit(100000)
MyProcess.CloseMainWindow()
MyProcess.Close()
Thanks in advance,
Rick
I've tried everything, it always goes to the default printer.
My Code:
Dim pathToExecutable As String = "WINWORD.EXE"
Dim SPrinter = \\PrinterPath\PrinterName 'Name Of printer
Dim sReport = "C:\WordDoc1.doc" 'Complete name/path of PDF file
Dim starter As New ProcessStartInfo(pathToExecutable, "/t " + sReport + " "
+ SPrinter + "")
Try
Dim MyProcess As New Process
'MyProcess.StartInfo.Arguments = "/t " + sReport + " " + SPrinter + ""
MyProcess.StartInfo.CreateNoWindow = False
MyProcess.StartInfo.Verb = "print"
MyProcess.StartInfo.FileName = sReport
'MyProcess.StartInfo = starter
MyProcess.Start()
Dim iloop As Int16 = 0
If MyProcess.HasExited = False Then
'if not then loop for 100 time to try and close the process'with 10 seconds
delay
While Not MyProcess.HasExited
System.Threading.Thread.Sleep(10000)
MyProcess.CloseMainWindow()
iloop = CShort(iloop + 1)
If iloop >= 100 Then
Exit While
End If
End While
End If
MyProcess.WaitForExit(100000)
MyProcess.CloseMainWindow()
MyProcess.Close()
Thanks in advance,
Rick