Results 1 to 3 of 3

Thread: StartInfo.Verb = “PrintTo” on vb.net 2010 not working for jpg file but work on pdf?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Question 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

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Re: StartInfo.Verb = “PrintTo” on vb.net 2010 not working for jpg file but work on pd

    Quote Originally Posted by .paul. View Post
    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
  •  



Click Here to Expand Forum to Full Width