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-2021 by Barry MacDonnell. All Rights Reserved.

Page updated Jul 21, 2019

"Date Inserter" - View a scrollable calendar and quickly insert any selected date into your document in various formats (including "legal-style" dates) - Optionally have the macro add or subtract "x" days from the selected date.

Download DateIns.zip (v1.04; 07/21/2019; 11,657 bytes)

Compatible with WordPerfect X6 but should work in other versions back to WP8

Downloading, Documentation, Modifications, and Support


Date Inserter.wcm is a macro that displays a dialog on screen
(screen shot) with a date field that lets you pick a desired date from a calendar (or simply type in a desired date).

It then inserts that date at the current cursor location with the click of a push button, in any of several different formats.

Example default formats -

        June 17, 2019

        Monday, June 17, 2019

        the 17th day of June, 2019


Other options let you -

        add or subtract "x" days from the desired date before inserting the date,

        display the selected date on screen only, or

        add bold formatting to the date.

Note that the inserted date is a "static" date -- it will not automatically change to the current date if the document is saved and opened at a later time. For that, you should use WordPerfect's menu: Insert, Date/Time, <choose a date/time format>, enable the checkbox "Keep the inserted date current," and click Insert.


The current version of this macro gets the current user's date format from Windows (stored in Control Panel; Region and Language). It assumes the "short" date is displayed in the format of M/d/yyyy -- e.g., August 12, 2014, as used in the English (United States) format. It will not work with other date formats. [Hopefully this will be fixed in the future, although the macro language presents certain difficulties when using a calendar tool in a dialog.]


Simply place the cursor where you want the date inserted in the document and then play the macro. Choose the desired date and other options, then press the appropriate push button. (A menu checkbox option lets you display the date on screen in a message box dialog instead of inserting it; press OK to dismiss the dialog.)


•  Several menu items can be set to other defaults in the User Modification Area at the top of the macro's code.

•  Dates in the Date Inserter macro (and the alternative macro below) follow the Month-Day-Year format. To change date formats that are inserted by the push buttons on the main menu see the comments at the top of the macro's code.

•  Macro writers:
Here's a snippet of code that can be used (and modified if required) in a macro to type the current (system) date into a document in legal format (e.g., "the 17th day of June, 2019":

// Macro snippet begins

// = = = = =
// (insert optional code here to position the cursor where desired)
// = = = = =

// First, get date components from the user's system -
// the StrTrim() command removes any leading zero
in the system variable ?DateDay -

vDay:=StrTrim (?DateDay;;TrimLeft!;"0")

// Then insert the date in "legal" format at the cursor position -
Type ("the "+fAbbrevDay(vDay)+" of "+fMonthName(vMonth)+", "+vYear)


// = = = =  =

// The Functions below return the month and day for use in the Type() command:
// (Original function code snippets by John Land)
// = = = = = 

Function fMonthName (vInStr)
    Return (vMonthList[vInStr])

Function fAbbrevDay (vInDay)
    Switch (vInDay)
        CaseOf "01";"1";"21";"31": vOutDay=vInDay+"st"
        CaseOf "02";"2";"22": vOutDay=vInDay+"nd"
        CaseOf "03";"3";"23": vOutDay=vInDay+"rd"
        Default: vOutDay=vInDay+"th"
    Return (vOutDay)  // Returns the proper format (e.g., "31st")

// Macro snippet ends