Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch print PDF files from VB

Posted on 2003-11-20
17
Medium Priority
?
805 Views
Last Modified: 2008-01-16
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
0
Comment
Question by:bagirex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
17 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 1000 total points
ID: 9789750
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9789837
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9797282
hi, any progress on this? some feedback would be nice.
Cheers
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:bagirex
ID: 9801542
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
 

Author Comment

by:bagirex
ID: 9801642
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9809955
Of course, you could do that way:
classname for acrobat is (at least 5.0) is:
Afx:400000:8: 10011:0:a510219
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9809963
by the way, i misread your comment, it IS searching by its window title.
0
 

Author Comment

by:bagirex
ID: 9811370
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9811743
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9813335
Classname for version 6.0.0 in "AdobeAcrobat"
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9813478
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
 

Author Comment

by:bagirex
ID: 9818260
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9818497
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9874324
Hi, any progress on this?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question