1 Reply Latest reply on Apr 22, 2008 11:19 AM by Peter Kahrel

    How to find Object Styles

    Tom Tomasko Level 1

      Adobes Scripting Guide: JavaScript explains well(more or less) how to find text, greps and glyph. But lacking is how to find Object Styles. The Find/Change Dialog box in ID does have this option.

      What I would like is a script that will find a style, then fill in the color of that style so that one can clearly see in a long document where the style was used. When there are only subtle differences between styles, this is helpful.

      The first thing to do is to clear all the options and that is my first stumbling block. In the following code the first line works, clearing the find of any parameters. The second line does not work.

      app.findObjectPreferences = NothingEnum.nothing;
      app.findChangeObjectOptions = NothingEnum.nothing;

      I also need to set the Search for Documents (not All Documents nor Selection) and to set the Type for All Frames.

      The second obstacle is setting the Find so that it will find the object I am looking for. The code below does not work but I do not know why.

      app.findObjectPreferences.getElements("Object Style 1");

      Any help is appreciated.
        • 1. Re: How to find Object Styles
          Peter Kahrel Adobe Community Professional & MVP
          You need this:

          app.findObjectPreferences = null;
          app.findObjectPreferences.appliedObjectStyles = "Object Style 1";
          found_objects = app.activeDocument.findObject();

          Some things are different in scripting compared to the interface. For instance, the scope of the search in the interface is just "document" or "all documents", but in a script you can search a page, a spread, almost anything (I have to say that this is true for text and grep searches, I never tried it for objects). Finding frame types is different as well: there's no parameter for that I don't think. Instead, you have to find all frames that have a particular object style applied to them, then cycle through them checking their frame type; if the type matches your criteria, do what you want with it.