Reply to topic  [ 8 posts ] 
selection before first cell of table 
Author Message

Joined: 2007-04-12 14:59:36
Posts: 229
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.


2010-12-16 05:15:46
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
This ought to do the trick:
Code:
If TableSelection.active
   Select Table Cell 1,1
   Select Start
End


2010-12-16 09:03:22
Profile WWW

Joined: 2007-04-12 14:59:36
Posts: 229
Thank you Martin.
Unfortunately I still don't know how to make my macro work. It starts with the lines

Code:
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?


2010-12-16 11:27:14
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.


2010-12-16 12:58:44
Profile WWW

Joined: 2007-04-12 14:59:36
Posts: 229
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


2010-12-16 14:33:34
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
It works for me. If I select something in the 2nd column before the macro runs, eg:
Attachment:
Picture 1.png
Picture 1.png [ 12.11 KiB | Viewed 4608 times ]

And run your macro, the table has been sorted by the 2nd column, eg:
Attachment:
Picture 2.png
Picture 2.png [ 12.2 KiB | Viewed 4608 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 Start

To the very end of the macro.


2010-12-16 16:41:31
Profile WWW

Joined: 2007-04-12 14:59:36
Posts: 229
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.


2010-12-17 02:11:46
Profile

Joined: 2007-04-12 14:59:36
Posts: 229
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.


2010-12-17 02:23:28
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software