1. Create a floating cell at the cursor location:
On the top menu (assuming you are using a WordPerfect menu),
click Table, Create, <Floating cell radio button>, Create.
In Reveal Codes you should see [FltCell>|<FltCell], where
the red vertical line indicates the current cursor position.
2. In the Table formula bar that should be
visible above the document area, click inside the blank field
(to the right of the blue checkmark), and type this formula into
that field:
+DATETEXT(DATEVALUE(DATE())-1)
Or:
+DATETEXT(MDY()-1)
3. Click the blue check mark. The calculated
date should appear between the pair of [FltCell] codes in the
document, as a text string.
4. Click Close on the formula bar. The [FltCell]
codes can be deleted in Reveal Codes, since they have done their
job of creating the static date.
Each macro calculates "x" days from
either the current (system) date or from another, specified date.
They will then insert that new date in the document as a (static)
text string inside a floating cell. (Floating cells cannot
be created inside another table; hence, the initial code segment
that pops a warning message.)
Examples #3 and #4 might be good candidates
for a template macro that can be triggered
automatically. For more on how to automate
a template, see the main Tips page, here.
Note that the resulting floating cell (i.e.,
everything bracketed by [Flt Cell] codes, and including those
codes) can be copied elsewhere in the document. Or you can add
a DeleteCharPrevious command after the FloatingCellFormula command,
as was done below (but disabled with comment marks ("//")).
This will delete the [FltCell] codes as part of a "clean
up" process.
To copy any of these macros into your WordPerfect
program see here.
Example #1 - Use the current date, calculate
a new date (+/-) "x" days from that date, based on
a number of days the user inputs into a small dialog.
// Macro code begins:
If(?InTable)
Messagebox(; "Error";
"You cannot play this macro inside a Table.")
Return
Endif
OnCancel(End@) // (used
in case the user exists the GetNumber dialog)
vDate:= DateString() //
(stores today's date)
GetNumber(vDays;
"How many days from today?"+NToC(0F90Ah)+
"(use a minus sign for past days)";
"Insert a Date +/- 'x' Days from Today")
FloatingCellCreate
FloatingCellFormula("+DATETEXT(DATEVALUE("""+vDate+""")+"+vDays+")")
// DeleteCharPrevious // (optionally delete floating cell codes)
Label(End@)
Return
// End of macro
Example #2 - Use a static date other than
the current date, calculate a new date (+/-) "x" days
from that date, based on a number of days the user inputs into
a small dialog.
// Macro code begins:
If(?InTable)
Messagebox(; "Error";
"You cannot play this macro inside a Table.")
Return
Endif
OnCancel(End@) // (used
in case the user exists the GenNumber dialog)
// Example: Store "January
15, 2009" as a static date in vDate:
vDate:=DateString(DateAndTime(15;1;2009))
GetNumber(vDays;
"How many days from today?"+NToC(0F90Ah)+
"(use a minus sign for past days)";
"Insert a Date +/- 'x' Days from Today")
FloatingCellCreate
FloatingCellFormula("+DATETEXT(DATEVALUE("""+vDate+""")+"+vDays+")")
// DeleteCharPrevious // (optionally delete floating cell codes)
Label(End@)
Return
// End of macro
Example #3 - Use the current date, calculate
a new date that is a specified number of days from that date.
// Macro code begins:
If(?InTable)
Messagebox(; "Error";
"You cannot play this macro inside a Table.")
Return
Endif
vDate:= DateString() //
(stores today's date)
vDays:= -90 //
(e.g., minus 90 days)
FloatingCellCreate
FloatingCellFormula("+DATETEXT(DATEVALUE("""+vDate+""")+"+vDays+")")
// DeleteCharPrevious // (optionally delete floating cell codes)
Return
// End
of macro
Example #4 - Use the current date, calculate
a new date that is a specified number of days from that date.
(Similar to Example #3.) Note that in Example
#3 you could remove the vDate and vDays commands, and use just the following FloatingCellFormula() command, which is the equivalent to them. It will
calculate a new date that is minus 90 days (in this example)
from the current date (MDY()). So, this example is merely a simpler
version of Example #3:
// Macro code begins:
If(?InTable)
Messagebox(; "Error";
"You cannot play this macro inside a Table.")
Return
Endif
FloatingCellCreate
FloatingCellFormula("+DATETEXT(MDY()-90)")
// DeleteCharPrevious // (optionally delete floating
cell codes)
Return
// End
of macro