11 Replies Latest reply on Sep 29, 2016 4:07 AM by Suzan.V

    change in locked stories (GREP)

    Suzan.V Level 1

      Hi all,

       

      i'm seeking a way to do change in all locked stories without need to unlock them.

       

      i tried a lot in scripting but i only found a way to change in hidden layers not locked stories or text frame

       

      is it possible to do in scripting because i found it possible but on apple coding

       

      Thanks

       

      Suzan

        • 1. Re: change in locked stories (GREP)
          tpk1982 Level 4

          I hope you included in this lines before find and change (if you usie Grep search)

           

          app.findChangeGrepOptions.includeLockedStoriesForFind = true;

          • 2. Re: change in locked stories (GREP)
            Suzan.V Level 1

            well, i used your advice as shown on below code but still no thing changed on locked layers (stories)

             

            main();  
              
            function main() {  
                var doc = app.activeDocument;  
            
            
                app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;  
                  
                app.findChangeGrepOptions.includeLockedStoriesForFind = true;      
            
            
                 app.changeGrepPreferences.appliedFont = "Arial"; 
                app.findGrepPreferences.fontStyle = "Regular";  
            
            
                app.changeGrepPreferences.appliedFont = "Myriad Pro";  
                app.changeGrepPreferences.fontStyle = "Bold";  
                doc.changeGrep();  
                app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING; 
                
                }
            
            • 3. Re: change in locked stories (GREP)
              milligramme Level 3

              Hi

               

              .includeLockedStoriesForFind

               

              try of locked layer

               

              .includeLockedLayersForFind

               

              You can only find in locked stories and layers, to change you should unlock stories (from InCopy?) or layers.

               

              thankyou

              mg.

              • 4. Re: change in locked stories (GREP)
                tpk1982 Level 4

                try this..

                 

                main(); 

                 

                function main() { 

                    var doc = app.activeDocument; 

                 

                 

                    app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING; 

                     

                    app.findChangeGrepOptions.includeLockedStoriesForFind = true;     

                  app.findChangeGrepOption.includeLockedLayersForFind = true;

                 

                     app.findGrepPreferences.appliedFont = "Arial";

                    app.findGrepPreferences.fontStyle = "Regular"; 

                 

                 

                    app.changeGrepPreferences.appliedFont = "Myriad Pro"; 

                    app.changeGrepPreferences.fontStyle = "Bold"; 

                    doc.changeGrep(); 

                    app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

                   

                    }

                • 5. Re: change in locked stories (GREP)
                  Suzan.V Level 1

                  milligramme wrote:

                   

                  Hi

                   

                  .includeLockedStoriesForFind

                   

                  try of locked layer

                   

                  .includeLockedLayersForFind

                   

                  You can only find in locked stories and layers, to change you should unlock stories (from InCopy?) or layers.

                   

                  thankyou

                  mg.

                   

                  i tried both lines but no thing changed, this means that there is no way to change text inside locked stories or layers and i have to unlock it first ??

                   

                   

                  Suzan

                  • 6. Re: change in locked stories (GREP)
                    milligramme Level 3

                    Hi,

                     

                    Generally using `[target].changeGrep()` won't work.

                     

                    I found another way, this work for me (cc version9.3) without unlocking textframes and layers.

                     

                     

                    main();
                        
                      
                    function main() {
                      var doc = app.activeDocument;
                        
                      var find_grep_obj = {
                        appliedFont: "Arial",
                        fontStyle: "Regular",
                      };
                      var change_grep_obj = {
                        appliedFont: "Myriad Pro",
                        fontStyle: "Bold",
                      };
                    
                    
                      with (app.findChangeGrepOptions) {
                        // includeFootnotes            = false;
                        // includeHiddenLayers         = false;
                        includeLockedLayersForFind  = true;
                        // includeLockedStoriesForFind = true;
                        // includeMasterPages          = false;
                        // kanaSensitive               = true;
                        // widthSensitive              = true;
                      }
                      
                      var match = grep_find(doc, find_grep_obj);
                      for (var mi=0, mlen=match.length; mi < mlen ; mi++) {
                        var container = match[i].parentStory.textContainers;
                    
                    
                        for (var ti=0, tlen=container.length; ti < tlen ; ti++) {
                          // without unlocking
                          // container[ti].locked = false;
                          // container[ti].itemLayer.locked = false;
                        };
                        for (var prop in change_grep_obj) {
                          match[mi][prop] = change_grep_obj[prop];
                        };
                      };
                      
                      function grep_find (target_obj, find_grep_obj) {
                        app.findGrepPreferences = NothingEnum.nothing;
                        app.findGrepPreferences.properties = find_grep_obj;
                        var result = target_obj.findGrep();
                        app.findGrepPreferences = NothingEnum.nothing;
                        return result;
                      }
                    }
                    

                     

                    thank you

                    mg.

                    1 person found this helpful
                    • 7. Re: change in locked stories (GREP)
                      Suzan.V Level 1

                      i got this error and no thing changed

                       

                      1.png

                      • 8. Re: change in locked stories (GREP)
                        tpk1982 Level 4

                          use this..

                         

                        app.findChangeGrepOptions.includeLockedLayersForFind = true;

                         

                         

                        "s" missing in findChangeGrepOptions

                        • 9. Re: change in locked stories (GREP)
                          Suzan.V Level 1

                          unfortunately same result

                           

                          did that code work for you? i'm afraid that  may be my application or file is corrupted..

                           

                          sorry for bothering you again and again.

                           

                          Suzan

                          • 10. Re: change in locked stories (GREP)
                            Suzan.V Level 1

                            Dear mg, thanks a lot my dear works perfect and awesome

                             

                            many thanks again for your help and time..

                             

                            cheers

                             

                            Suzan