selection before first cell of table

Get help using and writing Nisus Writer Pro macros.
Post Reply
js
Posts: 259
Joined: 2007-04-12 14:59:36

selection before first cell of table

Post by js »

If the cursor is in a table, how can a macro set it at the start of the table (it is: before any text in the first cell of the first row).
Select start seems to work only if there is no text before the table.
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: selection before first cell of table

Post by martin »

This ought to do the trick:

Code: Select all

If TableSelection.active
	Select Table Cell 1,1
	Select Start
End
js
Posts: 259
Joined: 2007-04-12 14:59:36

Re: selection before first cell of table

Post by js »

Thank you Martin.
Unfortunately I still don't know how to make my macro work. It starts with the lines

Code: Select all

Columns
Copy
select table
Assuming the the cursor is anywhere within Column X I should now have a copy of the column on the clipboard and the table should be selected.
If the Table is topmost on my document this works. If there is any text before is doesn't. I don't understand this.
What should be my next line if I want the cursor to be at the beginning of Cell 1,1?
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: selection before first cell of table

Post by martin »

Your macro works for me, regardless of where the table is in the document, and how many tables are in the document. What do you mean by it doesn't work? Do you mean the column is copied, but the table is not fully selected? If not, what exactly is selected after the macro runs?

Perhaps there's something more peculiar about your document- maybe posting it would help.
js
Posts: 259
Joined: 2007-04-12 14:59:36

Re: selection before first cell of table

Post by js »

OK Is send the complete macro (which served to do simple column sorts in a Nisus table:

HERE IS MY FILE:
# file start
With this line the macro complains about an error; without it it works
1 pear first
2 apple second
3 orange third
# file end

HERE IS MY MACRO:
# My Sort Macro:
Columns
Copy
select table
Select Start
Paste
select table
Ascending (A-Z)
Select Start
Columns
Delete
# end of Sort Macro
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: selection before first cell of table

Post by martin »

It works for me. If I select something in the 2nd column before the macro runs, eg:
Picture 1.png
Picture 1.png (12.11 KiB) Viewed 11480 times
And run your macro, the table has been sorted by the 2nd column, eg:
Picture 2.png
Picture 2.png (12.2 KiB) Viewed 11480 times
Is that not what you're seeing? If you simply want the insertion point to be in the first table cell after the macro runs, add the line:

Code: Select all

Select Start
To the very end of the macro.
js
Posts: 259
Joined: 2007-04-12 14:59:36

Re: selection before first cell of table

Post by js »

I dont' know how to put a screen photo on this list. I send it to you by mail attachment. Maybe you could put it on the list for me.
On the photo you can see how my macro complains as soon as the table is not on top. Without that it works fine for sorting small tables within Nisus.
js
Posts: 259
Joined: 2007-04-12 14:59:36

Re: selection before first cell of table

Post by js »

Martin, I guess I should have added this:

My whole purpose to want the cursor at the beginning of cell 1 is for inserting a copy of the column I want to be sorted, the one where I put the cursor at the outset.
Afterwards haveing copied that column, the whole table has to be selected, to apply the sort order to the whole table, not only to the first column.
After that, the copied column can be deleted. Of course the macro would look a bit nicer if the insertion point could go back to where it was at the beginning.
Post Reply