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

Tagged: ,

Viewing 5 reply threads
  • Author
    Posts
    • #100328
      Morgan Waage
      Member

      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.

    • #100329

      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);
      
    • #100331
      Peter Kahrel
      Participant

      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).

    • #100347
      Morgan Waage
      Member

      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?

    • #100348
      Peter Kahrel
      Participant

      clearObjectStyleOverrides removes object style overrides, not paragraph overrides. Maybe try

      app.activeDocument.textFrames[0].paragraphs.everyItem().clearOverrides(OverrideType.ALL);

    • #100349
      Morgan Waage
      Member

      app.activeDocument.textFrames[0].paragraphs.everyItem().clearOverrides(OverrideType.ALL);

      didn’t work.
      But, using parentStory.texts[0] instead of paragraphs.everyItem() did work

      app.activeDocument.textFrames[0].parentStory.texts[0].clearOverrides(OverrideType.ALL);

      Thanks for the help guys.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
>