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

Re: Print PDF from VBA by Mark

Mark
Sat Mar 10 08:03:29 CST 2007

In case anyone's interested, I found a nice one already:
PDF Toolkit. http://www.accesspdf.com/index.php?topic=pdftk

It's a DOS program, but not much work to build a VBA macro that runs it.

And it's free!

MT


Mark Tangard wrote:

> 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
>


Re: Print PDF from VBA by jim

jim
Mon Mar 12 07:41:23 CDT 2007

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



On Sat, 10 Mar 2007 06:03:29 -0800, Mark Tangard
<Mark@RemoveThisToReply_Tangard.com> wrote:

>In case anyone's interested, I found a nice one already:
>PDF Toolkit. http://www.accesspdf.com/index.php?topic=pdftk
>
>It's a DOS program, but not much work to build a VBA macro that runs it.
>
>And it's free!
>
>MT
>
>
>Mark Tangard wrote:
>
>> 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
>>

Re: Print PDF from VBA by Karl

Karl
Mon Mar 12 16:39:52 CDT 2007

Mark Tangard <Mark@RemoveThisToReply_Tangard.com> wrote:
> 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

--
.NET: It's About Trust!
http://vfred.mvps.org