Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2023 by Barry MacDonnell. All Rights Reserved.

Page updated Jun 7, 2023

SaveAsPDF - A macro to automate saving the current document as a PDF file to any drive or folder

Download SaveAsPDF.ZIP (v1.01; 03/27/19; 14,351 bytes)

Compatible with WordPerfect WPX6 (v. and later versions.

WordPerfect 11 users: See important information about using macros in the first release of WP11 ( at the top of this page.

Downloading, Documentation, Modifications, and Support

Related pages -

Publishing to PDF with WordPerfect 9 and later versions (tips on the feature and some simple macros)

Purpose and operation

When you have more than a few PDF files to create from WordPerfect documents, or PDF(s) to create from the same file(s) on a frequent basis, SaveAsPDF.wcm can help automate the task.

Note that the macro uses WordPerfect's own File, Publish to PDF feature to create and save the current on-screen document as a PDF file — but unlike the standard Publish to PDF feature it can save the PDF to a specified drive and folder.

The specific PDF location can be easily changed when the macro plays from a pop up menu (or more permanently with a simple modification to the macro as described below):

SaveAsPDF macro menu

This can be useful if you want to quickly convert several open documents to PDFs and store them in a different location, rather than the same location as the on-screen document which is the WordPerfect program default (and the macro default when you use it without modification).

Just play it while the cursor is in any open WordPerfect document. You can then verify and optionally change the target drive and folder (in the first field, which also has a Browse button), and if desired, change the name of the PDF file that will be generated when you click OK.

Main advantages

•  Your preferred default folder for the generated PDF file can be specified (i.e., made relatively permanent) inside the macro's redlined User Modification Area at the top of the macro code.


In the download version of the macro, the folder that is specified as the preferred default is the same folder as your current on-screen WPD document — which is the way WordPerfect's Publish to PDF feature works.

This location also acts as a "placeholder" for the menu's first field, and will of course work, but —
to accomplish the main purpose of the SaveAsPDF.wcm macro, you probably will want to change that folder to your preference.

Just [1] open the macro like any document to edit it and [2] follow the brief instructions in the User Modification Area 
to change the value of a single variable (vPDFLocation =) to your desired drive and path.

Example settings:

vPDFLocation = "D:\Temp\" 
... or ...

vPDFLocation = "C:\Users\{UserName}\OneDrive\Documents\"
... i.e., any valid drive and path (double quotes required in the code).

When finished modifying the macro, be sure to click the Save & Compile button on the macro's toolbar (or just use File, Save on the main WordPerfect menu).


☼  Even if you have specified a preferred default folder for the PDF in the macro code, you can still change that location whenever the menu appears by using the first field.

☼  You can suppress (i.e., hide) the confirmation message that appears when you click OK on the menu by changing a single variable (vMsg =) in the User Modification Area.

☼  Advanced users: An alternative to the SaveAsPDF macro can be constructed following the instructions in the Corel Tutorials here and here, published several years ago
   The first link also shows how to create a custom PDF style
in the Publish to PDF's Settings module that can be used in the macro when it generates the PDF document. (It does this via the macro command PDFStylesSetActive("<yourstylename>") just above the PDFDlg() command.)But note that such changes to the Publish to PDF's Settings -- even made manually be the user at any time -- are "sticky" between WordPerfect sessions. For more see the Caveats section below.

•  The PDF filename
in the download version is the same name as the existing WPD's name, but you can change it in the menu's second field
when you play the macro.

The macro will automatically add a .pdf filename extension to the PDF name at run time. However, you can always change the PDF's filename from the macro's menu.

Tip: If you often need to use several specific folders to store your PDFs, you could make several copies of this macro (named slightly differently and with different default folders specified at the top of the macro code) and add them to your menu, main toolbar (or a custom toolbar) or even to a dedicated macro menu. For more see here for links to these topics.


WordPerfect's Publish to PDF feature displays a dialog ("Publish to PDF") with several options on it. Further, there is a Settings button on the dialog, which brings up another dialog ("Publish to PDF Settings").

On that second dialog's General tab you can (e.g.) choose between Full Document, Current Page, a Selection of text, or a particular group of pages.

Other tabs on that "Publish to PDF Settings" dialog have more options (most users typically accept the factory default settings).

It is important to note that the choices you make on the main "Publish to PDF" and the "Publish to PDF Settings" dialogs in WordPerfect are "sticky" between WordPerfect sessions. 

Hence, the SaveAsPDF macro will use the program's last-saved settings for the Publish to PDF feature when it creates and saves the current document as a PDF file.
(There's a small reminder to verify the Publish to PDF settings on the macro's pop up menu.)

For most users this should not be an issue. But (e.g.) this sometimes becomes a problem if changes were made to the Publish to PDF dialog or its Settings. (Any changes can "stick" until they are changed again.) Here are two examples:


If you always want the PDF to immediately open in your PDF reader as soon as it is created, the checkbox "Open PDF After Saving" at the bottom of the Publish to PDF dialog should be enabled (ticked). If it not enabled the PDF will be created ... but it won't be automatically opened.


If you have chosen something other than Full Document with the Settings button (e.g., Current Page) your new choice becomes the default for future sessions, and can cause concern if you might be expecting the standard default of Full Document. Just bring up the Publish to PDF feature from the program's File menu and click the Settings button to verify the current settings and options.

See more on this issue and other PDF tips here.