Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Macro to print a PDF document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MIrving - 10 Dec 2007 05:02 GMT
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.
zkid - 12 Dec 2007 20:48 GMT
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"

> I would like to set up a macro that prints a PDF document to whatever the
> default printer is that the user has.
[quoted text clipped - 5 lines]
>
> Thank you for any suggestions.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.