Why doesn't this line of code work
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Why doesn't this line of code work
- This topic has 5 replies, 3 voices, and was last updated 6 years, 3 months ago by Morgan Waage.
-
AuthorPosts
-
-
December 14, 2017 at 1:28 am #100328Morgan WaageMember
Why doesn’t this line of code work?
app.activeDocument.textFrames[0].clearOverrides(OverrideType.ALL);
I get an error saying it is not a function. I thought clearOverrides() was the function. OverrideType.ALL was the parameter and the function is run on textFrames[0] on the activeDocument.
-
December 14, 2017 at 1:58 am #100329Kai RübsamenMember
In such situations it is better to work not with one line, instead move from one object to the next and check if the object is valid and if so, what is the correct name of the property.
// the active document var curDoc = app.activeDocument; // the last created textframe var lastTextFrame = curDoc.textFrames[0]; // a textframe has no property 'clearOverrides', but 'clearObjectStyleOverrides'! lastTextFrame.clearObjectStyleOverrides(OverrideType.ALL);
-
December 14, 2017 at 5:07 am #100331Peter KahrelParticipant
Check the object model in some viewer. clearOverrides() is not a property or function of text frames, only of text objects (words, characters, lines, etc).
-
December 15, 2017 at 12:47 am #100347Morgan WaageMember
clearObjectStyleOverrides doesn’t give me an error but it doesn’t remove the overrides on my paragraph.
Anyone know how I can remove the overrides on my paragraph?
-
December 15, 2017 at 1:07 am #100348Peter KahrelParticipant
clearObjectStyleOverrides removes object style overrides, not paragraph overrides. Maybe try
app.activeDocument.textFrames[0].paragraphs.everyItem().clearOverrides(OverrideType.ALL);
-
December 15, 2017 at 1:52 am #100349Morgan WaageMember
app.activeDocument.textFrames[0].paragraphs.everyItem().clearOverrides(OverrideType.ALL);
didn’t work.
But, using parentStory.texts[0] instead of paragraphs.everyItem() did workapp.activeDocument.textFrames[0].parentStory.texts[0].clearOverrides(OverrideType.ALL);
Thanks for the help guys.
-
-
AuthorPosts
- You must be logged in to reply to this topic.