Greetings,
hope all are fine
I am using vb.net 2010
i am trying to print jpg/image file in (theoretically) any type of file in background to specific printer.
so, i am using startinfo.verb = "PrintTo"
here is the used code:
it works for doc,pdf files but when i try jpg file it not.Code:Dim objStartInfo As New ProcessStartInfo Dim objProcess As New System.Diagnostics.Process Dim sreport As String = "d:\Wallpaper\Personal Picture\X\DSC_0000500.jpg" but not here :( 'Dim sreport As String = "c:\Documents and Settings\Y\Desktop\Zakir\New\requirements.pdf" rem works for pdf file 'Dim sreport As String = "g:\My Documents\Word\Budget.doc" rem even works for document file Dim sPrinter As String = "Microsoft Office Document Image Writer" Dim iloop As Integer Try objProcess.StartInfo.CreateNoWindow = True objProcess.StartInfo.UseShellExecute = True objProcess.StartInfo.FileName = sreport objProcess.StartInfo.Arguments = """" & sPrinter & """" objProcess.StartInfo.Verb = "PrintTo" objProcess.StartInfo.CreateNoWindow = True objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden objProcess.Start() If objProcess.HasExited = False Then iloop = 0 While Not objProcess.HasExited System.Threading.Thread.Sleep(100) iloop = CShort(iloop + 1) cmdProcess.Text = iloop.ToString Me.Refresh() If iloop >= 300 Then Exit While End If End While End If objProcess.CloseMainWindow() objProcess.Close() objProcess.Dispose() objProcess = Nothing Catch ex As Exception MessageBox.Show(ex.Message) End Try
It shows error "No application is associated with the specified file for this operation"
i am so confused?
thanks in advance
best regards





Reply With Quote
