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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.