Get help using and writing Nisus Writer Pro macros.
5 posts • Page 1 of 1
- Official Nisus Person
- Posts: 4567
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
You do not need to convert the table to text; the macro language lets you work with table cell text directly. Assuming the selection currently rests in a table, here's a macro that tells you a little bit about the selected table:
Code: Select all
# Get the first table selection $selection = TableSelection.active If ! $selection Prompt 'This macro only works if some part of a table is already selected.' Exit End $selectedRow = $selection.rowRange.location # first selected row $selectedCol = $selection.columnRange.location # get the table that is selected, and inspect some cells $table = $selection.table $firstCellText = $table.textAtRowAndColumn(0,0) $firstSelectedCellText = $table.textAtRowAndColumn($selectedRow,$selectedCol) Prompt "The text of the first selected cell: $firstSelectedCellText", "The text in the first cell of the table is $firstCellText"
But how about text formatting? I can see from your example how to retrieve unattributed text from individual cells. But what I need is complete rows that have a sear word in one of the cells, with formatting. Would this be easier by first transforming the table into text?
Those variables are attributed text. It is Prompt command that shows them as plain text. Try to output them to a new file, for example.js wrote:But how about text formatting? I can see from your example how to retrieve unattributed text from individual cells.
It is your way of describing the problem that confused Martin, I think. If you had asked simply “How to get (the text of) the rows of a table that contain a search word?”, then you should have got something like this.But what I need is complete rows that have a sear word in one of the cells, with formatting.
which will put the text in the clipboard.
Code: Select all
Menu ':Table:Select:Rows' Menu ':Table:Copy Table Text'