Page 1 of 1

How can I change spacing after paragraph with a macro?

Posted: 2007-07-05 08:40:35
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....)


Posted: 2007-07-05 14:23:36
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.

Posted: 2007-07-09 08:48:19
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?


Posted: 2007-07-09 15:26:56
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

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