3 Replies Latest reply on Aug 11, 2014 12:07 AM by Jump_Over

    Master page

    kanaga kumar

      Dear Friends,

       

      My script is find the paragraph style ("CN") and replaced the "CO" master page. It is showing the error from highlighted "master page line" (see below).

       

      var myDoc = app.activeDocument

      var myPages = myDoc.pages.everyItem().getElements();

      for (i=0; i<myPages.length; i++){

          var myPage = myPages[i]

          var myParas = myPage.textFrames.everyItem().paragraphs;

          if (myParas[0].appliedParagraphStyle.name=="CN");

          {

       

       

              myPage.appliedMasterPage="CO-Master";

              }

                  }

       

      Thanks

      kanaga kumar. k

        • 1. Re: Master page
          Chinnadk Level 4

          Hi Kanaga kumar,

           

          Try this.

           

          var doc = app.activeDocument;
          app.findTextPreferences = null;
          app.findTextPreferences.appliedParagraphStyle = "CN"
          var found = doc.findText();
          app.findTextPreferences = null;
          for(var i =0;i<found.length;i++)
          {
                  found[i].parentTextFrames[0].parentPage.appliedMaster = doc.masterSpreads.item("CO-Master");
              }
          

           

          Regards,

          Chinna

          • 2. Re: Master page
            Vipul-Bansal Level 1

            Hi Kanaga,

             

            There is no comand with the name "appliedMasterPage".

            Can you try out "appliedMaster"?

             

            Thanks,

            Vipul

            • 3. Re: Master page
              Jump_Over Level 5

              Hi,

               

              Writing a script keep contact with Object Model.

              There is no such property "appliedMasterPage" but "appliedMaster"

              This property does not accept string (alike appliedCharacterStyle or fillColor do) but an object directly, so:


               

              myPage.appliedMaster = myDoc.masterSpreads.item("CO-Master);

               


              should work


              Jarek