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® |
Page updated Aug 18, 2024 |
|
"Date
Inserter"
- Displays a dialog to input and convert a chosen date to one of several date formats, including legal-style (ordinal) dates, then type (insert) it into the current document at the cursor location. Options include automatically adding or subtracting "n" days to the chosen date, and/or just displaying the converted date rather than inserting it. [Update August 2024: Additional example code snippets are described below to help automate the quick insertion of "legal-style" dates at the cursor location.] |
||
|
Purpose Date Inserter.wcm (v1.05, updated Aug. 17, 2024) is a macro that displays a dialog on screen with a date field that lets you pick a desired date from a drop-down calendar (or simply type the desired date in a menu field). It then inserts that date at the current cursor location with the click of a push button, in any of several different formats. Examples of the date formats - August 17, 2024 [standard US version] Saturday, August 17, 2024 [day of week plus standard date] the 17th day of August, 2024 [ordinal date in numerals+suffix] the seventeenth day of August, 2024 [ordinal date in words] 8/17/2024 [numerical with separators] [Tip: Several formats can be modified. See Notes below.] Other options let you - add (or subtract) "n" days to the desired date before inserting it display the date on screen only add bold formatting to the date Note that the inserted date
is a "static" date --
i.e., it will not automatically change when the document is saved and opened at a later time. For automatic date/time changes you can
manually use WordPerfect's menu: Insert, Date/Time, <choose a
date/time format>, enable the checkbox "Keep the inserted date
current," and click Insert. That feature inserts a dynamic
date (via a format code) that changes when the current date changes.
Dynamic dates can be useful to "stamp" a document with the then-current
print date and time, revision date, etc. The current version of this macro gets the current user's date format
from Windows (stored in the Windows Settings: search Settings for
"Region"). It assumes the
"short" date is displayed in the format of M/d/yyyy -- e.g., 8/17/2024
(August 17, 2024), as used in the English (United States) format. It
will not work without modification to accommodate 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, such as used in Date Inserter.wcm.]
Instructions First, extract the Date Inserter.wcm macro from inside the downloadable ZIP file. [See "Downloading..." instructions if you need help with this.] 2. Choose
the desired date by typing it into the top-left date field or by using the drop-down calendar tool. Note that manually typed
dates into the date field are not checked for validity (just follow the
format shown in the field). However, the calendar tool will always
produce a valid date. 3. Choose from the other options. [One is a checkbox that lets you display the date on screen in a message box dialog instead of inserting it; press OK to dismiss the message and end the macro.] 4. Press the appropriate date
format push-button on the right side of the dialog. This inserts the
chosen date in the document and ends the macro. • You can edit the Date Inserter macro like any other WordPerfect document. The best way is to use the WordPerfect menu: Tools > Macro > Edit. • The Date Inserter macro has several menu items which can be set to other defaults in the redlined User Modification Area at the top of the macro's code. • Dates in the Date Inserter macro's code (and the alternative plain-text macro code below) follow the Month-Day-Year format. To change date formats and/or the order of date components that are inserted by several of the push buttons on the macro's main menu, see the comments at the top of the macro's code. Additional code snippets for experienced macro users [1] type the current (system) date into a document [2] as a static date (see above - and also "Limitations") [3] in "legal" format [4] using ordinal numbers. Notes ¤ The first example snippet uses numerals in the ordinals (1st, 2nd, 3rd ... 31st.). For example, "the 17th day of August, 2024". ¤ The second example snippet below spells out the ordinals. For example, "the seventeenth day of August, 2024". ¤ Both snippets can be used inside substructures such as Headers, Footers, Footnotes, Endnotes, Tables, and Text Boxes. ¤ You can modify the Type() commands to add or delete words, spaces, or punctuation marks. Just be sure these items are enclosed in pairs of double quote marks, as shown in the examples. ¤ To copy such plain-text code into your WordPerfect program to create a working macro see https://wptoolbox.com/tips/CopyCode.html. Example #1 // Macro snippet begins: // First, get the 3 date components from // The two Functions below return the current month This example snippet is the same as Example #1 -- but spells out the ordinals. // Macro snippet begins: |
|
|