Print PDF from VBA

M

Mark Tangard

A long shot, maybe: Is there way, maybe using Shell, to print a PDF file from
VBA code?

Goal: To print all PDFs in a folder *in order* (alpha by filename), in a way
that doesn't require opening each one or combining them into a large file(s).

Selecting multiple PDF files from an Explorer window and clicking File-> Print
does in fact send them to printer, but the print in some bizarre order I can't
discover!

Can I use VBA's FileSearch property to collect the filenames & then call another
macro within that loop that sends each file to the printer, with a DoEvents line
(or some equivalent to Background:=False) after each one, so they'll print one
at a time?

Is this clear? Is there an easier way somewhere?

Word 2003, WinXP, Acrobat 6.0 standard.

Thanks in advance
Mark Tangard
 
J

jim

Mark -

Do a search on adobe.com for "Programming Acrobat JavaScript Using
Visual Basic". It is Tech Note #5417 published in August 2002. I
have used it to program some simple stuff with VB6 to save PDFs to
various directories based on content, something JavaScript is weak on
but that VB6 can do easily. The nice thing about it is that it is all
VB based and you don't need to go to DOS.

I am sure that will meet your needs.


jim
 
K

Karl E. Peterson

Mark Tangard said:
A long shot, maybe: Is there way, maybe using Shell, to print a PDF file from
VBA code?

Goal: To print all PDFs in a folder *in order* (alpha by filename), in a way
that doesn't require opening each one or combining them into a large file(s).

I'd think you could do that with a series of ShellExecute calls using the "print"
verb. Try this:

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

Public Function PrintDoc(ByVal DocFile As String) As Long
' Uses the "print" verb as defined in the registry
PrintDoc = ShellExecute(0&, "print", DocFile, vbNullString, vbNullString,
vbNormalFocus)
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top