Skip to main content
brifilone
Participating Frequently
January 28, 2011
Answered

[mac OS/AS] how do I apply a paragraph style using applescript?

  • January 28, 2011
  • 1 reply
  • 1461 views

I got the new way to talk to a labeled text box down but can't seem to figure out how to word it to apply a paragraph style

set AttGet to "Try to put this text in"

tell application "Adobe InDesign CS2"

activate

tell document 1

set contents of text frame 1 whose label is "Attention getter" to AttGet --YES

--here is how we used to do it in earlier CS versions (CS2 & 3)

set applied paragraph style of every paragraph of parent story of text frame "Attention getter" to "Paragraph Style X"

-- that errors so i tried these to no avail!
--set applied paragraph style of every paragraph of parent story of text frame 1 whose label is "Attention getter" to "Paragraph Style X"--FAILS

--set applied paragraph style of contents of text frame 1 whose label is "Attention getter" to "Paragraph Style X" --FAILS

-- set applied paragraph style of text of text frame 1 whose label is "Attention getter" to "Paragraph Style X" --FAILS

end tell

end tell

This topic has been closed for replies.
Correct answer Muppet_Mark-QAl63s

Why not set a reference to the frame if found by the 'whose' filter then use that?

set AttGet to "Try to put this text in"

tell application "Adobe InDesign CS5"

activate

tell document 1

try

set AttGetTF to the first text frame whose label is "Attention getter"

log AttGetTF

set contents of AttGetTF to AttGet

set applied paragraph style of every paragraph of parent story of AttGetTF to "Paragraph Style X"

on error

display dialog "Text Frame \"Attention getter\" NOT found?" giving up after 3

end try

end tell

end tell

1 reply

Inspiring
January 28, 2011

Your original statement:

set applied paragraph style of every paragraph of parent story of text frame "Attention getter" to "Paragraph Style X"

works for me in CS4. Are you really trying to do this for CS2, as the "tell app" line says, or are you in CS4?

If it's CS4, is the paragraph style you're referencing part of a paragraph style group? That would make it error if you don't include a reference to the style group name.

brifilone
brifiloneAuthor
Participating Frequently
January 29, 2011

Sorry I should have clarified at home I have CS2 at work I use CS5.

I sent the question from home so it says CS2

The usual statement that I always used is not working anymore in CS5

set applied paragraph style of every paragraph of parent story of text frame "Attention getter" to "Paragraph Style X"

Muppet_Mark-QAl63s
Muppet_Mark-QAl63sCorrect answer
Inspiring
January 29, 2011

Why not set a reference to the frame if found by the 'whose' filter then use that?

set AttGet to "Try to put this text in"

tell application "Adobe InDesign CS5"

activate

tell document 1

try

set AttGetTF to the first text frame whose label is "Attention getter"

log AttGetTF

set contents of AttGetTF to AttGet

set applied paragraph style of every paragraph of parent story of AttGetTF to "Paragraph Style X"

on error

display dialog "Text Frame \"Attention getter\" NOT found?" giving up after 3

end try

end tell

end tell