13 Replies Latest reply on Dec 25, 2013 7:43 AM by DNY1803

    How to apply a Character Style that's already been made in a template document?

    Scorpio17523 Level 1

      First of all I'd like to thank everyone that helps. I'm a complete beginner at scripting and appreciate all your help.


      I'm basically using GREP expressions to find patterns in a document and apply a Character Style which has already been made. This Character style was not made using script, but just in InDesign when making and setting up the template.


      var myDoc = app.activeDocument;
      //Clear the find/change grep preferences.
      app.findGrepPreferences = NothingEnum.nothing;
      app.changeGrepPreferences = NothingEnum.nothing;
      //Set the find options.
      app.findChangeGrepOptions.includeFootnotes = false;
      app.findChangeGrepOptions.includeHiddenLayers = false;
      app.findChangeGrepOptions.includeLockedLayersForFind = false;
      app.findChangeGrepOptions.includeLockedStoriesForFind = false;
      app.findChangeGrepOptions.includeMasterPages = false;
      //GREP Expression for finding all HEADERS
      app.findGrepPreferences.findWhat = ".+\n";
      //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
      app.changeGrepPreferences.capitalization = Capitalization.allCaps;
      app.changeGrepPreferences.fontStyle = "Bold";
      app.changeGrepPreferences.pointSize = "12";
      //Clear the find/change preferences after the search.
      app.findGrepPreferences = NothingEnum.nothing;
      app.changeGrepPreferences = NothingEnum.nothing;


      This is how I currently have it. I will manually define the changes to the text. The problem is, each template uses a different set of fonts and not all of them use Bold e.g. Sabon can use CE Bold.


      I would like to learn how to apply a Character Style and have tried looking around but nothing seems to work.


      Any help would be much appreciated.