1 Reply Latest reply on Jul 17, 2017 5:27 AM by Steve Werner

    Map paragraph styles to object styles

    Saranya M Level 1

      Hi,

       

      How to map or load all paragraph styles to object styles using scripts?

      I am using the below script for mapping all the paragraph styles to object styles but it is not working. Please do guide me.

       

      #include "glue code.jsx"

      main();

      function main(){

      if (app.documents.length != 0){

      var myDoc = app.activeDocument;

      var myRuleSet = new Array (

      new findObjAttribute("//*[@href]")

      );

      with(myDoc){

      var elements = xmlElements; //alert(elements);

      __processRuleSet(elements.item(0), myRuleSet);

      }

      }

      else{

      alert("You have no document open!");

      exit();

      }

      function findObjAttribute(XPATH){

      this.name = "findObjAttribute";

      this.xpath = XPATH; //alert(this.xpath );

      this.apply = function(myElement, myRuleProcessor)

      {

      //Just to check whether the collect element is selected

      var elmName=myElement.markupTag.name;

      alert(elmName);

      var styleName=myElement.xmlAttributes.itemByName("href").value;

      alert(styleName);

      with(myElement){

      try {

      applyObjectStyle(myDoc.objectStyles.item(styleName), true);

           } catch(e){};

      }

      return true;

      }

      }

      }

       

      Regards,

      Saranya