I'm trying to appy an object style to a faux ad. The style places the ad were is should be positioned on the page.
But I keep getting an error when I run the script, so I'm sure I have some sytax issues, but I don't know how to correct the issue. I would appreicate any help anyone can offer.
Here is what I have so far.
var mySelection = app.selection;
app.selectionappliedObjectStyle(app.activeDocument.objectStyles("FR Top Ad"),true);
app.menuActions.itemByName('Bring to Front').invoke();
var myObj = app.selection;
myObj.rotationAngle = -5;
You're missing a period between selection and appliedObjectStyle.
In addition to what @brianp311 metioned I also notice that the name of the method is wrong on that line, it should be applyObjectStyle
See the documentation
So the line should be
app.selection.applyObjectStyle(app.activeDocument.objectStyles("FR Top Ad"),true);
Thanks, Manan and brianp311.
I changed the line, but I'm still getting an error message (screen shot below).
I've tried moving the line around, thinking perhaps I have it out of order. But that doesn't work either.
I think I'm missing something else, but I can't figure it out.
I appreciate you taking the time to help me out.
Maybe try ...object styles.itemByName("FR Top Ad",true);
Weird one. No weird line break before the function call.
instead of objectStyles("name") do objectStyles.itemByName("name").
app.selection.applyObjectStyle( app.activeDocument.objectStyles.itemByName("FR Top Ad") );
FWIW: I see the same error "Object is not a function" if I do:
app.selection.applyObjectStyle( app.activeDocument.objectStyles("FR Top Ad") );
The second argument is optional. Its default value is true. So you can drop it.
( ACP )
That worked. Fantastic.
I couldn't figure out what I had wrong in the text.
one other question.
This object style is in a folder inside the Object Style folder.
Is there a way to make the script "look" inside another folder. It's called Advertising, if that helps any.
Thanks again for your help.
app.selection.applyObjectStyle( app.activeDocument.objectStyleGroups.itemByName("Advertising").objectStyles.itemByName("FR Top Ad") );
That worked great.....
Fabulous.....I appreicate everyone's help on this.
I was trying different configuations and getting nowhere.
I appricate everyone taking the time to help me out.