Batch print PDF files from VB

Hi,
I want to be able to silently print batch pdf files from VB using user's default printer.
Using shell "AcroRd32 -p " command opens up print dialog that I don't need, and it can print only one pdf.


Thanks
bagirexAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vinnyd79Commented:
Have you using ShellExecute API to print? If you add a FilelistBox you can loop through it printing each document:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Load()
File1.Pattern = "*.pdf"
File1.Path = "C:\Somefolder"
End Sub

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To File1.ListCount - 1
    Call ShellExecute(hwnd, "Print", (File1.Path & "\" & File1.List(i)), "", "", 0)
Next i
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richie_SimonettiIT OperationsCommented:
I did a little example here:
http://www.angelfire.com/realm/vb-shared/pdf_print.xls
What you need to avoid dialog box is using /T modifier instead of p.
0
Richie_SimonettiIT OperationsCommented:
hi, any progress on this? some feedback would be nice.
Cheers
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

bagirexAuthor Commented:
I am using WIN2K, Vb6, Acrobat 6.0
Sorry about being late on this.

vinnyd79,
Thanks, it is working except Acrobat window is left open.
How to close it?
Will it work on other that WIN platforms?

Richie_Simonetti,

in modmain
Do
    ' Please check that caption of acrobat is correct,
    ' otherwise this loop will never ends.
    l = FindWindow(vbNullString, "Acrobat Reader - [" & filename & "]")
Loop While l = 0

When I've commented out all but
ShellExecute 0, "print", "C:\Program Files\Adobe\Acrobat 6.0\Reader\Acrord32.exe /t " & filename, vbNullString, vbNullString, vbHide
it didn't work either.

It kept looping.
0
bagirexAuthor Commented:
Richie_Simonetti,

Just read
    ' Please check that caption of acrobat is correct,
comment more carefully. Is it good idea to find acrobat instance by it's window title?
Might be differet with different versions.
0
Richie_SimonettiIT OperationsCommented:
Of course, you could do that way:
classname for acrobat is (at least 5.0) is:
Afx:400000:8: 10011:0:a510219
0
Richie_SimonettiIT OperationsCommented:
by the way, i misread your comment, it IS searching by its window title.
0
bagirexAuthor Commented:
At least the good news is Acrobat Reader allows only one running instance.
Afx:400000:8: 10011:0:a510219 for classname didn't work. Mine is Adobe 6.0
0
Richie_SimonettiIT OperationsCommented:
Well, if classname doesn't works, we have to moveback to findwindow api.
Please, check how acrobat show its caption with version 6.0
0
Richie_SimonettiIT OperationsCommented:
Classname for version 6.0.0 in "AdobeAcrobat"
0
Richie_SimonettiIT OperationsCommented:
Well, since only one instance is allowed, use code from vinnyd, just replace p modifier with t modifier.
Maybe you could call shellexecute with full path to acrobat exe only the first time and others calls to print other docs should use " /t " & filename as lpFile parameter (just a guess)
0
bagirexAuthor Commented:
Richie,

1.  How do you find out classname for Adobe versions? I checked my registry and couldn't find it
2. Vinnyd doesn't use any modifier. It uses only 'print' , which doesn't have modifiers!?

thanks
0
Richie_SimonettiIT OperationsCommented:
1) there is a tool that comes with Visual studio called Spy, you could use it to know the class name from every window. Just moving the cursor over it.
2) Modifiers were hard to find for me but, as long as i know, using T as modifier, it doesn't shows you dialog box.
0
Richie_SimonettiIT OperationsCommented:
Hi, any progress on this?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.