Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Dim psi As New ProcessStartInfo("C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe")
        psi.UseShellExecute = True
        psi.Verb = "print"
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.FileName = "D:\abc.pdf"
        Process.Start(psi)


i am using this code to print pdf from a vb.net program as found on the googling. but when i run this code it shows "no program is associated with this process".Can any one help me with solution?
Posted

1 solution

VB
ProcessStartInfo("C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe")
uses double quotes to make VB aware of a string between them. They are working fine.

When VB passes that string to the OS, it removes the double quotes (they are just for programming in VB anyway). That makes the string appear as several strings separated by spaces: C:\Program, then Files\Adobe\Reader and 11.0\Reader\AcroRd32.exe. That's not what a process expects to see.

Try this one
VB
ProcessStartInfo("""C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe""")
The outermost double quotes remain. But inside the string, there are two doubled double quotes, which VB translates into two double quotes that remain in the string when it's passed to the OS.
 
Share this answer
 
Comments
VipinKumar Maurya 13-May-14 6:10am    
Thanks it worked for me! but Can you please help me with a new query.?
how to get the printing parameters from user i.e printer and other inputs parameter that appear in the print dialog. Actually I want to loop this print function for multiple documents but need to show dialog only once and have the same setting for all the documents supposed to be printed.
lukeer 13-May-14 7:18am    
I'm afraid not. I have no idea how printing that way actually works.
My experiences with .NET printing are based on the PrintDocument class (there's an example on the linked site). This way, you can use a PrintDialog to ask user for printing properties and use them for as many documents as you wish. But I don't know how to get a .pdf into that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900