|
-
Jan 25th, 2015, 09:59 AM
#1
Thread Starter
Hyperactive Member
StartInfo.Verb = “PrintTo” on vb.net 2010 not working for jpg file but work on pdf?
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:
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 works for doc,pdf files but when i try jpg file it not.
It shows error "No application is associated with the specified file for this operation" 
i am so confused?
thanks in advance
best regards
-
Jan 25th, 2015, 06:17 PM
#2
Re: StartInfo.Verb = “PrintTo” on vb.net 2010 not working for jpg file but work on pd
you probably need to associate *.jpg file types with an application, for example Paint:
http://stackoverflow.com/questions/1...on-with-vb-net
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 25th, 2015, 06:27 PM
#3
Thread Starter
Hyperactive Member
Re: StartInfo.Verb = “PrintTo” on vb.net 2010 not working for jpg file but work on pd
 Originally Posted by .paul.
you probably need to associate *.jpg file types with an application, for example Paint:
thanks for the reply though.. but i don't think that
by association it means what program a file will be open with right? if user double click or right click then open? right?
Normally my jpg file is associated with irfanview image viewer, but for that error i even tried to associate Photoshop to jpg file. but same error
however, thanks for your help again..
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|