Skip to main content
Participating Frequently
October 1, 2025
Answered

Object Style issues with Applescript

  • October 1, 2025
  • 2 replies
  • 196 views

I'm having two issues with Object Styles in Applescript. First, there's creating the object style...

 

set mystyle to make new object style of mydoc
tell mystyle
set name to "3rd Party"
set fill color to "Paper"
set stroke color to "Black"
set stroke weight to 0.5
set stroke type to "Solid"
set properties of text frame preferences to {ignore wrap:true, inset spacing:{"1p0", "1p0", "1p0", "1p0"}, auto sizing type:off}
end tell

 

It does everything except the text frame preferences. I've phrased it every way I can think of but none of the text frame preference settings work.

 

Second, I can't get it to apply the object style to a text frame. 

 

tell myframe
set applied object style to object style mystyle
end tell

 

Again, I've tried multiple phrasing options and nothing happens. 

 

Any clues out there?

Correct answer leo.r
quote

Second, I can't get it to apply the object style to a text frame. 

 

tell myframe
set applied object style to object style mystyle
end tell


By @Bryan Colley

 

This indeed won't work because object style is not an element of text frame (it's an element of application, documents, and object style groups).

 

You need to do either

 

set applied object style of myframe to object style styleName

 

or

 

set os to object style styleName

 

tell myframe

set applied object style of myframe to os

end tell

2 replies

leo.r
Community Expert
leo.rCommunity ExpertCorrect answer
Community Expert
October 1, 2025
quote

Second, I can't get it to apply the object style to a text frame. 

 

tell myframe
set applied object style to object style mystyle
end tell


By @Bryan Colley

 

This indeed won't work because object style is not an element of text frame (it's an element of application, documents, and object style groups).

 

You need to do either

 

set applied object style of myframe to object style styleName

 

or

 

set os to object style styleName

 

tell myframe

set applied object style of myframe to os

end tell

Participating Frequently
October 1, 2025

Aha! That worked. Thank you. 

leo.r
Community Expert
Community Expert
October 1, 2025
quote

It does everything except the text frame preferences. I've phrased it every way I can think of but none of the text frame preference settings work.


By @Bryan Colley

 

I can't reproduce it. I'm running your code, and the text frame preferences are being set up as defined in the script.

 

What are your InDesign and macOS versions?

Participating Frequently
October 1, 2025

Well, since I posted things have gotten weirder...

 

The script actually does create the object style with the text frame preferences, but those text frame preferences don't show up in InDesign unless I open the Edit Object Style dialogue, click on Text Frame General Options and look at them, then close the dialogue and override the applied style.  So it just seems to be a quirky issue with InDesign and not the script. 

 

However, I still can't get the script to apply the Object Style to a text frame. I have to do that manually.

 

I'm using InDesign 2024 and Mac OS Sequoia 15.7 (about to upgrade to 15.7.1)

leo.r
Community Expert
Community Expert
October 1, 2025
quote

The script actually does create the object style with the text frame preferences, but those text frame preferences don't show up in InDesign unless I open the Edit Object Style dialogue, click on Text Frame General Options and look at them, then close the dialogue and override the applied style.


By @Bryan Colley

 

Yes, this I can reproduce.

 

At this point, looks like a bug. I need to test it some more.