Macro to print a PDF document

M

MIrving

I would like to set up a macro that prints a PDF document to whatever the
default printer is that the user has.

I don't want the PDF document to open and I would also prefer that the print
dialog box doesn't open. In other words, the user can click on a 'print
form' button on the toolbar and the PDF document automatically prints to
their default printer.

Thank you for any suggestions.
 
Z

zkid

Thanks to Jean-Guy Marcil’s entry last May, I just tweaked his
OpenAcrobatFile code to get your answer.

Place the following “paragraph†at the top of the module:

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

The code below is its own sub that does the actual work

Public Sub PrintPDF(strFile As String)
ShellExecute 0, "print", strFile, vbNullString, vbNullString, 9
End Sub

Now, in your actual “macro†subroutine, place the following line:

PrintPDF "C:\[FilePathHere]\[DocNameHere].pdf"
 

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