How to script Table Delete Rows?

Everything related to our flagship word processor.
Post Reply
ssampler
Posts: 85
Joined: 2006-06-29 07:56:30
Location: Hudson River Valley, NY

How to script Table Delete Rows?

Post by ssampler »

I'm on OS X 10.6.8. NWP 2.04
I've written several Apple scripts to manipulate tables, so that I can call them by name with LaunchBar. I'm stumped on how to delete selected rows in a table. In the manual, P. 418, are the examples:

Code: Select all

Do Menu Macro with macro "FormatFontTimes"
Do Menu Macro with macro "FontBold"
By analogy with these, either of:

Code: Select all

Do Menu Macro with macro "TableDeleteRows"
Do Menu Macro with macro "DeleteRows"
should work, but neither does, stopping with an error: "Unknown Menu Item Path"

I notice one difference between these and the previous two : "Rows", a choice in the Table Delete sub-menu, is also a choice in the Table Select sub-menu. In the first two examples, on the other hand, "Bold" and "Times" do not appear in any other sub-menu. In fact,

Code: Select all

Do Menu Macro with macro "Times"
Do Menu Macro with macro "Bold"
both work, because they define unique sub-menu items.

Steve
Steve Samuels
sjsamuels@gmail.com

User avatar
martin
Official Nisus Person
Posts: 4925
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: How to script Table Delete Rows?

Post by martin »

Hi Steve,

When working with ambiguous command names, you'll need to specify a full (or partial) menu path, using a colon character as a path separator. So instead of just "Rows" you'll need "Delete:Rows" or ":Table:Delete:Rows".

Putting that all together in an AppleScript would look like:

Code: Select all

tell application "Nisus Writer Pro"
	Do Menu Macro with macro ":Table:Delete:Rows"
end tell
I hope that does the trick— let us know if you have any other questions.

ssampler
Posts: 85
Joined: 2006-06-29 07:56:30
Location: Hudson River Valley, NY

Re: How to script Table Delete Rows?

Post by ssampler »

Thanks, Martin!

The solution seemed familiar, and it was, once: http://www.nisus.com/forum/viewtopic.ph ... 9722#p9722. I also see the example on page 402 of the manual. The initial colon doesn't appear to be necessary.

I appreciate NWP tables more than ever now. They are perfect for logging data analyses, and "Merge Cells" (also scripted) gives me room for long comments.

Steve
Steve Samuels
sjsamuels@gmail.com

User avatar
martin
Official Nisus Person
Posts: 4925
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: How to script Table Delete Rows?

Post by martin »

Happy to help– I'm glad that did the trick, and to hear you're making good use of tables and macros!

Post Reply