Written by Allen Wyatt (last updated September 15, 2021)
This tip applies to Word 2007, 2010, 2013, and 2016
In Mary's office they routinely create PDF files from Word documents. They do this by using Save As and choosing to save the document as a PDF file. This seems rather "click intensive" to Mary, so she wonders if there is a shortcut available, within Word, for saving a document as a PDF file.
There are two ways that you can approach this task. First, you could add a command to Quick Access Toolbar:
Figure 1. Adding a command to the Quick Access Toolbar.
This tool, when clicked, displays a dialog box that looks very much like a Save As dialog box. All you'll need to do is to provide the name you want used for the PDF file and, optionally, pick a folder where you want the file saved.
You can take a similar approach through the use of a macro, if desired. The difference is that this approach actually does display the Save As dialog box.
Sub SaveAsPDF1() With Dialogs(wdDialogFileSaveAs) .Format = wdExportFormatPDF .Show End With End Sub
As with all macros, you can add it to the Quick Access Toolbar or create a shortcut key to invoke it.
Both approaches discussed so far display a dialog box into which you must type a file name and pick a location for the PDF file. If you want to bypass the dialog box completely, a different macro approach may work for you.
Sub SaveAsPDF2() Dim sName As String Dim sPath As String With ActiveDocument sName = Left(.Name, InStr(.Name, ".") - 1) sName = sName & ".pdf" sPath = .Path & "\" .ExportAsFixedFormat _ OutputFileName:=sPath & sName, _ ExportFormat:=wdExportFormatPDF End With End Sub
This macro figures out the folder for the currently open document and then saves the PDF into that folder using the same name as the document. So, for instance, if you are working on a document called "MyDoc.docx," then this macro will save the PDF as "MyDoc.pdf." No dialog box is displayed; the PDF file is simply created and saved.
If you prefer for your PDF files to be saved in a different folder, all you would need to do is assign the full path to that folder to the sPath variable. As an example, let's say that you want all your PDF files to be saved in a common folder. Just replace this line:
sPath = .Path & "\"
with a line similar to this one, modified for your desired path:
sPath = "c:\mypath\pdfs\"
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12240) applies to Microsoft Word 2007, 2010, 2013, and 2016.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
Many printers these days have the capability to print on both sides of a piece of paper. You may want Word to use this ...
Discover MoreNeed to print a copy of a document but you don't care if it looks as "pretty" as you want the final printout to look? You ...
Discover MorePutting words on the printed page is easy in Word. Rotating those words in different manners can be a bit trickier. This ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-12-20 13:16:21
Kevin Shrav
Fantastic. The time and effort savings are astronomical!
2021-01-19 11:03:14
Mateusz
will this work also on outlok?
I need to safe email as pdf once it moves to certain folder
2020-11-04 11:45:42
RF
Consider using InstrRev() to search for the last period so it doesn't cut off your filename when you have multiple periods.
2020-07-29 10:27:39
Morty
Thank you for pointing out the Publish As PDF button for my MS Word that's been there all along and just today for some reason I decided to "see if there is a way" to simplify a few clicks. As I PDF every Word doc I create daily. You just saved 1000s of seconds of my life moving forward.
2020-07-23 11:54:23
Sam P
This was really easy to follow and to the point. Thank you.
2019-01-31 06:34:34
fabulous, made my day, thanks!
2019-01-18 12:28:12
LTom
Hello Allen,
I have been using PDF1 macro to save a file to PDF.
I would like the PDF file to open automatically after I it is saved.
Can you please help me with the command line to be added for that functionality?
Thanks,
2019-01-16 17:42:04
Allan
I use Word 2007. I am unable to find "File tab" ANYWHERE on ANY of the Choose Commands From... options.
2019-01-15 23:27:16
Jefu
Thanks for this tip. It was exactly what I was looking for and solved a pesky problem. Much appreciated.
2017-08-07 08:02:38
Juanita H.
A huge thank you for this tip. You have no idea how much this is going to simplify my job.
2017-08-06 02:50:50
Ken Endacott
HSK
Your error message is occurring because the statement starts with a period and is not preceded by a With statement. If you are using the SaveAsPDF2 macro most likely you have inserted the sPath = .Parh & “\” statement outside the With grouping.
With … End With is used as follows:
The statements:
Selection.Font.Bold = True
Selection.Font.Italic = True
Selection.Font.ColorIndex = wdBlue
are equivalent to:
With Selection.Font
.Bold = True
.Italic = true
.ColorIndex = wdBlue
End With
2017-08-01 07:04:02
Richard
Small correction - In the Word 2007 interface, in Word Options, choose commands from Office Menu. In Word 2010 and later, choose commands from File tab.
2017-07-31 16:51:06
Jackie Oliveira
You can also save a document as a .pdf by going to your print menu and using the DocuCom PDF Driver. Simple and fast.
Jackie Oliveira
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments