Print Acrobat Reader PDF file from VBA

M

Matthias Claes

I'm trying to print a given Acrobat Reader PDF file from VBA. (Office 2000 &
Acrobat Reader 6)
I've included the reference to the Adobe Acrobat Control for ActiveX
(pdf.ocx),
but I'm unable to actually create an instance of the PDF control.
I've also tried putting a Microsoft Webbrowser control an my Excel
worksheet, and calling the
Webbrowser1.Navigate "\\someserver\somefolder\somefile.pdf" method.
The webbrowser control indeed shows the PDF file, but I did not find a way
to print it's contents from VBA.

I'm looking for someone who can put me on the right track for this seemingly
simple problem.

Matthias Claes
matthias.claes(-at-)stadsbader.com
 
M

Matthias Claes

I'm trying to print a given Acrobat Reader PDF file from VBA. (Office 2000
& Acrobat Reader 6)

I've found a solution. using the follwing link
http://vb.mvps.org/samples/project.asp?id=HyperJmp

Using the ShellExecute WinAPI call, you may execute a 'verb' associated with
a file extensions.
So, declare ShellExecute as follows in a module:

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

and print your document using the following call:

Dim result As Long
result = ShellExecute(0&, "print", "\\someserver\somefolder\somefile.pdf",
vbNullString, vbNullString, vbNormalFocus)



Matthias Claes
matthias.claes(-at-)stadsbader.com
 

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