How can I change spacing after paragraph with a macro?

Get help using and writing Nisus Writer Pro macros.
Post Reply
Derick
Posts: 107
Joined: 2007-05-21 08:33:59

How can I change spacing after paragraph with a macro?

Post by Derick »

To clean up some imported documents, I’m trying to write a macro that will set the spacing after a paragraph to 0 pt (they’re getting imported with it set to 12 pt). But as far as I can tell, this setting can only be changed from the Paragraph palette in the Tooldrawer, not from a menu. Does this mean there is no way to access it from a macro?

If not, how can I do this? (please don't send me down the thorny path of UI Applescripting....)

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

Post by martin »

This seems to be an area where the menus (and thus macros) are somewhat deficient. There is no way to set just the paragraph spacing via a macro. Here's two options:

1. Apply a paragraph style to the text that has the proper spacing (eg: Normal). This should clear any ruler overrides. This obviously won't work if the style has been set to include paragraph spacing.

2. Include formatted text in the macro that has the ruler settings you want. Move that formatted text to the clipboard and then paste the ruler, eg:

Code: Select all

$plain = “text”
Write Clipboard $plain
Paste Ruler
Both of these options will unfortunately affect other ruler properties. I'll file some enhancement requests that makes this job easier.
js
Posts: 259
Joined: 2007-04-12 14:59:36

Post by js »

This macro did not work and I tried the following:

1. I have an open document with some text
2. I copy some words and edit the clipboard, giving it a shorter ruler
3. I go back to the original window and do Past Ruler

This should paste the edited clipboards ruler to my text, shouldn't it?
Well it doesn't. But if it doesn't how can your macro work?

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

Post by martin »

Sorry js, I forgot that when you copy/paste a ruler a special system clipboard is used for this purpose. Here's a revised macro that should do the trick:

Code: Select all

# save current selection for later
$selStart = Selection Location
$selLength = Selection Length

# copy the default ruler to the special ruler clipboard
Select All
Select Start
Insert Attributed Text "plain\n"
Remove Attributes and Styles
Copy Ruler
Delete

# apply the ruler to the originally selected text
Set Selection $selStart, $selLength
Paste Ruler
Post Reply