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 Mar 6, 2023 |
|
DELETERC - Deletes empty rows and (optionally) columns from a 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 -
Menu screen shot. Notes and tips ¤ Some items are
ignored: Cells with just regular
spaces (spacebar), format codes
(bold, italics, styles, outline numbers, etc.), and images
([Box] codes) are not considered "text" during processing. Therefore,
cells that contain only these items will be seen as empty during
processing. ☼ If you need
to select everything in a cell -- 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 |