• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1261
  • Last Modified:

Word Macro to print PDF

I need a macro to print an open document as a pdf and automatically put in the name of the output PDF to be the same as the incoming name.

It would also be good to be able to specify in the macro where the output PDF is going to be saved.

I tried to record one, but it hangs at the point where it asks what name to give it.

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
        ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
    With Options
        .UpdateFieldsAtPrint = False
        .UpdateLinksAtPrint = False
        .DefaultTray = "Use printer settings"
        .PrintBackground = True
        .PrintProperties = False
        .PrintFieldCodes = False
        .PrintComments = False
        .PrintHiddenText = False
        .PrintXMLTag = False
        .PrintDrawingObjects = True
        .PrintDraft = False
        .PrintReverse = False
        .MapPaperSize = False
        .PrintOddPagesInAscendingOrder = False
        .PrintEvenPagesInAscendingOrder = False
        .PrintBackgrounds = False
    End With
    With ActiveDocument
        .PrintPostScriptOverText = False
        .PrintFormsData = False
    End With

  • 4
  • 3
1 Solution
Joanne M. OrzechManager, Document Services CenterCommented:
What version of Adobe are you using?  You can set it in Adobe to capture the file name and create the PDF so all you have to really do is print the file to the PDF printer....

    ActivePrinter = "Adobe PDF"

Open in new window

911bobCTOAuthor Commented:
That does exactly what mine does.. It brings up the dialog box asking where and what name you want to save it as.

How do I get that to be fed in automatically so you do not have to specify the name or location?

Name should defautl to the MS Word Doc name
Joanne M. OrzechManager, Document Services CenterCommented:
It depends - what version of Adobe are you running?
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

911bobCTOAuthor Commented:
Joanne M. OrzechManager, Document Services CenterCommented:
Right click on Start, go to the Printers, right-click on Adobe PDF, go to Properties.  The first box that comes up has an option to "Prompt for Filename" - deselect that.

See if that works.
911bobCTOAuthor Commented:
It was actually under Printing preferences after I opened the properties dialog, but you can specify where it gets saves there.

Joanne M. OrzechManager, Document Services CenterCommented:
Excellent!  Glad to have been of assistance.  (I'm still running Adobe 6 Professional... so ....)

Word MVP
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now