Quote Originally Posted by kingpain View Post
The error I get is Win32Exception was unhandled "The system cannot find the file specified"

And I thought i did assign the file path as a string.


it works with the message box, it shows me that it has the file path as the correct location C:\temp\test6.pdf

Or maybe I'm not quite following you...

Thanks for your reply once again, it means a lot to me.
Well you didn't. Look at your code:
Code:
Imports System.IO
Imports System.Drawing


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pdffilename As String
        pdffilename = TextBox1.Text
        Dim filepath = "C:\temp\" & TextBox1.Text & ".pdf"
        Dim psi As New ProcessStartInfo
        psi.UseShellExecute = True

        psi.Verb = "print"

        psi.WindowStyle = ProcessWindowStyle.Hidden

        'psi.Arguments = PrintDialog1.PrinterSettings.PrinterName.ToString()

        psi.FileName = ("filepath") ' This works if i give the full location of my pdf file instead of the string "filepath"
        ' the messagebox will be removed this is just for testing.
        MessageBox.Show(filepath) ' to comfirm that I'm indeed finding the file at C:\temp\test01.pdf 

        Process.Start(psi) ' This is where the code fails. 


    End Sub

  

    Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub


End Class
You declare a 'psi' variable and you assign a ProcessStartInfo object to it and you have then used that variable thereafter. Now look at how you're trying to use the file path. You have declared a variable and assigned a value to it, i.e. a String that contains the file path. Have you then used that variable thereafter?