[2005] Printing File To Printer
Hey,
Does anyone know how to send a file directly to the printer, no matter what the file type is? I have a set of files currently that I double click on and they are sent directly to the printer. Or I am asked to define the file type. Can this be done in VB. Either printing direct to the printer, or performing a double click type scenario on the file through VB?
Re: [2005] Printing File To Printer
This code to work needs the file type to associated.
In this example you need to have Excel or Office installed.
Code:
Dim strFile As String= "c:\test.xls"
Dim objProcess As New System.Diagnostics.ProcessStartInfo
With objProcess
.FileName = strFile
.WindowStyle = ProcessWindowStyle.Hidden
.Verb = "print"
.CreateNoWindow = True
.UseShellExecute = True
End With
Try
System.Diagnostics.Process.Start(objProcess)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try