Skip to main content
Antony_Mooe
Inspiring
April 6, 2018
Answered

Select all items with object style "red" and change to style "blue"

  • April 6, 2018
  • 1 reply
  • 1195 views

Hello!

I want to select all items with object style "shadow 02" and apply object style "shadow 02".

Is that possible?

Thank you!

This topic has been closed for replies.
Correct answer FRIdNGE

Hi,

Of course! … A simplistic code could be:

app.findObjectPreferences = app.changeObjectPreferences = null;

app.findObjectPreferences.appliedObjectStyles = app.activeDocument.objectStyles.item("red");

app.changeObjectPreferences.appliedObjectStyles = app.activeDocument.objectStyles.item("blue");

app.activeDocument.changeObject();

app.findObjectPreferences = app.changeObjectPreferences = null;

Best,

Michel, from FRIdNGE

1 reply

Colin Flashman
Community Expert
Community Expert
April 7, 2018

The heading of the post doesn't match the question itself, but if you want to replace the red style with blue, you could do this without a script by going to the object styles panel and deleting the style in question. Once chosen, an option appears to replace the style with something else, and here the change can be made to the blue style.

Or is there something more involved that is required?

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
Antony_Mooe
Inspiring
April 7, 2018

Thank Colin for or replay.

I'm sorry, I didn't explain myself right.

I know it's possible to change object styles through the object styles panel, but I need to change it through a script.

I have several documents with 120 pages witch I have to change the style of specific items. I was wondering instead of doing it manually, use a script to automate the task.

Is that possible?

Thank you again

FRIdNGE
FRIdNGECorrect answer
April 7, 2018

Hi,

Of course! … A simplistic code could be:

app.findObjectPreferences = app.changeObjectPreferences = null;

app.findObjectPreferences.appliedObjectStyles = app.activeDocument.objectStyles.item("red");

app.changeObjectPreferences.appliedObjectStyles = app.activeDocument.objectStyles.item("blue");

app.activeDocument.changeObject();

app.findObjectPreferences = app.changeObjectPreferences = null;

Best,

Michel, from FRIdNGE