Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate |
![]() Toolbox for WordPerfect |
||
Macros, tips, and
templates for Corel® WordPerfect® for Windows® |
Page updated Feb 20, 2024 |
|
DELETERC - Deletes empty rows and (optionally) columns from a WordPerfect table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Related items - RowLines - Adds underlines and/or fills (shading) to every Nth row in a table for added readability or improved appearanceUsing WordPerfect tables (some tips) |
Purpose The DeleteRC.wcm macro ("Delete empty Rows and/or Columns") in the download ZIP archive (see left sidebar) can - • delete ALL EMPTY ROWS in the current table [the menu default] — i.e., those rows without any
visible (keyboard) characters, symbols, graphic boxes, or text boxes in any cell in the rows
after all rows are processed, see the first checkbox option below. -or- • delete ANY ROW where the first cell (i.e., in Column #1) is EMPTY — even if they might have visible characters, symbols, graphic boxes, or text boxes in other cells in the rows
empty rows will also be deleted. To also delete (or not) empty columns after all rows are processed, see the first checkbox option below. -or- • delete ALL EMPTY COLUMNS — i.e., no cells have visible content. This option retains any empty or partially empty rows
Also, if the first column is completely empty it can be skipped (i.e., retained). See the second checkbox option below. ![]()
Three check box options on the menu that modify the radio button choices:
□ The first check box ("When finished processing rows delete ALL EMPTY COLUMNS, too") — when ticked [the default] — will delete all
empty COLUMNS immediately following the macro's processing of the
table's rows (i.e., after you choose either of the first two radio
button options on the menu and click OK).
Tip: If you un-tick (i.e., clear) that first check box, the macro will not delete any empty columns when you choose either of the first two radio buttons on the menu.
□ The second check box ("Always retain COLUMN #1 -- even if it is empty") — when ticked [the default] — will retain the first column even if all its cells are empty. (Some users might want to use that column as a "check off" column or for some other purpose.) □ [New with v2.1] The third check box ("Display a dynamic message showing macro progress") — when ticked [the default] — will display a constantly and rapidly updated count of each deletion. (Note that a final tally message is always displayed.) The speed of updating the count can be slowed with a different default setting in the macro code (see tips below). After the macro completes processing a table it will display a final message showing the results: Original number of rows and columns, how many of each were deleted, and how many were kept.
Notes and tips ¤ Some items are
ignored: Cells with just regular
spaces (spacebar) and stray format codes
(bold, italics, styles, outline numbers, etc.) are not considered "text" during processing. Therefore,
cells that contain only these items will be seen as empty during
processing.
¤ On the other hand, WordPerfect symbols (Insert, Symbol... or Ctrl+w) and graphic or text boxes (which are produces with codes) are not ignored and their cells will be considered filled during processing. ¤ Menu (and other) defaults can be set in the redlined User Modification Area near the top of the macro code. Open the macro file (DeleteRC.wcm) for editing (Tools, Macro, Edit) and go to that area; make any changes; then click Save&Compile on the macro toolbar. ☼ [Macro writers:] If you need to select everything in a cell with a macro — format codes as well as text or other material — so that you can delete all items, see Footnote 1. Caution: Always make a backup of your document before playing this (or any)
macro, or
play it on a copy of your document. While you might be able to use
Edit, Undo (or Ctrl+z) to restore all changes to the table (depending
on your Undo options), it is always a good idea to have a backup
just in case. [Disclaimer]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Footnote 1 (Probably of interest mainly to macro writers) If you want to select the entire contents of a particular CELL — including all format codes, even those left behind be other operations — here's a Procedure that should do the job. (Tip: To select the contents of a particular row, see the second snippet of code.)
Basically the procedure selects any text and codes from the very top of
the cell to the very end of the last line EXCEPT Row or Cell or Table
terminators. The selection will include any [Hidden Txt] code — and
therefore the hidden text — as well as any format codes that lie
outside the cell's text character strings (e.g.,
[BoldOn]textstring[BoldOff]).
Most of the code came from the DeleteRC macro; the blue lines were added to capture any format codes at the top of the cell. The two WP51CursorMovement() commands (in green) ensure the code works even if Reveal Codes is turned off. The addition of the call to the procedure you see on the line just above the procedure itself (i.e., pSelectTableCellContents ()) is to prevent an error message if — for some reason — your main macro does not call the procedure (i.e., it's an "orphaned" code snippet). (The original code of this macro was also posted at WordPerfect Universe here.) // Select the current cell's contents:
pSelectTableCellContents () // ... do other stuff here, such as delete the contents with SelectDelete ... // Place this segment at the end of the macro: pSelectTableCellContents () Procedure pSelectTableCellContents () // Selects the entire contents of the current table cell: If(NOT ?TableInTable) // Test cursor position Messagebox(;"Error in macro Procedure";"Not in a table cell") Quit Endif WP51CursorMovement(On!) PosTableCellTop // Go before any items in cell - While(?LeftCode>0 and ?LeftCode<>{195;196;197;198}) PosCharPrevious // (moves before any codes except [Row], [Cell] etc.) Endwhile SelectMode(On!) // Turn select mode on - PosTableCellBottom // Go to the bottom of the cell - PosLineEnd // Go to the end of any line of text While(?RightCode>0 and ?RightCode<>{189;191;192;195;196;197;198}) PosCharNext Endwhile WP51CursorMovement(Off!) EndProcedure [Update:] To select the contents of a particular ROW - // Select the current row's contents:
pSelectTableCellContentsInCurrentRow () // ... do other stuff here, such as delete the contents with SelectDelete ... pSelectTableCellContentsInCurrentRow () Procedure pSelectTableCellContentsInCurrentRow () // Selects the entire contents of the current table row: If(NOT ?TableInTable) // Test cursor position Messagebox(;"Error in macro Procedure";"Not in a table cell") Quit Endif WP51CursorMovement(On!) PosTableCellTop // Go before any items in cell - While(?LeftCode>0 and ?LeftCode<>{195;196;197;198}) PosCharPrevious // (moves before any codes except [Row], [Cell] etc.) Endwhile SelectMode(On!) // Turn select mode on - PosTableRowEnd // Extend selection to end of row - PosTableCellBottom // Go to the bottom of the last cell - PosLineEnd // Go to the end of any line of text While(?RightCode>0 and ?RightCode<>{189;191;192;195;196;197;198}) PosCharNext Endwhile WP51CursorMovement(Off!) EndProcedure |