22 Replies Latest reply on Jan 12, 2017 6:04 AM by CreeDeaux

    Release all anchored objects at once

    mr.pathi

      Dear All, I want to release an all anchored objects from my file. All anchors are created inside the table. I am using InDesign CS4.

       

      I have a file for 4 pages which is containing more than 150 images to be released from anchored. That images should be placed in the same place. Only need to release. I want to do this for more than 100 files (400 pgs. it may increase in future). I tried this in Search/replace option using Object, but only i can able to find using custom option in the anchor options panel, not able to relase using search and replace.

       

      Please help me ASAP.

       

      Thanks in Advance, Thiru

        • 1. Re: Release all anchored objects at once
          winterm Level 4

          it seems your question already answered.

          take a look here:

          http://forums.adobe.com/message/2609468#2609468

          • 2. Re: Release all anchored objects at once
            mr.pathi Level 1

            Thanks for your reply. But I am new to scripting, so i am not able to make that script completely. So could you plz give me the full code of the script?

             

            For more information:

             

            The file contains Inline anchored object and custom anchored objects in the table. And there is no link between frames. Each page having separate frame.

            • 3. Re: Release all anchored objects at once
              csm_phil Level 4

              Hi Pathi,

               

              Please try the below js code is simple way to remove the anchored object for all the page.

               

               

              var myDoc =app.activeDocument;
              app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
              app.findTextPreferences.findWhat= "^a";
              myDoc.changeText();
              app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
              

               

              thx

              csm_phil

              • 4. Re: Release all anchored objects at once
                mr.pathi Level 1

                Hi CSM,

                 

                Thanks for your help. I copied this code and i run this script but while running this I am getting an error like below:

                 

                JavaScript Error!

                 

                Error Number: 1

                Error String: changeText

                 

                File: C\...

                 

                Line 4

                Source: myDoc.ChangeText();

                 

                 

                Could you plz check and let me know. Thanks in advance.

                • 5. Re: Release all anchored objects at once
                  csm_phil Level 4

                  Hi Path,

                   

                  Your wrongly entered the code myDoc.ChangeText() instead of myDoc.changeText();

                   

                  Please copy my previous code and run once again i think you typed wrongly.

                   

                  Please copy and paste estk and run the script.

                   

                   

                  var myDoc =app.activeDocument;
                  app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
                  app.findTextPreferences.findWhat= "^a";
                  myDoc.changeText();
                  app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
                  

                  mr.pathi wrote:

                   

                  Hi CSM,

                   

                  Thanks for your help. I copied this code and i run this script but while running this I am getting an error like below:

                   

                  JavaScript Error!

                   

                  Error Number: 1

                  Error String: changeText

                   

                  File: C\...

                   

                  Line 4

                  Source: myDoc.ChangeText();

                   

                   

                  Could you plz check and let me know. Thanks in advance.

                   

                   

                   

                  thx

                  csm_phil

                  • 6. Re: Release all anchored objects at once
                    mr.pathi Level 1

                    Hi CSM,

                     

                    I am sorry, I only copied the content from here to my script. So there it was correct only. When i replied a mail to you that time only i entered wrongly

                     

                    the code myDoc.ChangeText() instead of myDoc.changeText(); .

                     

                    So my script is correct as what you gave me. Its showing me the error:

                     

                    JavaScript Error!

                     

                    Error Number: 1

                    Error String: changeText

                     

                    File: C\...

                     

                    Line 4

                    Source: myDoc.changeText();

                     

                    sorry for the inconvenience. Thanks in advance.

                    • 7. Re: Release all anchored objects at once
                      winterm Level 4

                      hi Pathi,

                      Phil's script works, so better take a second look for copy-paste or somewhat errors on your side. Unfortunately, it not just releases anchores, it deletes them. This is not what you want, if I got your request.

                      Maybe Phil could adjust his code by chance?

                      • 8. Re: Release all anchored objects at once
                        csm_phil Level 4

                        Hi Pathi,

                         

                        Please try the below js code, Otherwise you can post your full code  i will check and clear your problem.

                         

                         

                        app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
                        app.findTextPreferences.findWhat= "^a";
                        app.activeDocument.changeText();
                        app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
                        

                         

                         

                        thx

                        csm_phil

                        • 9. Re: Release all anchored objects at once
                          mr.pathi Level 1

                          Hi winterm and CSM,

                           

                          @winterm : you are right. Its working fine as you said, its just deleting all anchored images also. But i dont want this, I want that images and should be placed in same place. It should just release from anchored.

                           

                          I have below script, even its working for normal file but its not working for the files which are need to release.

                           

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

                              var ad = app.activeDocument;

                              var pgit = ad.pageItems;

                              var pgitlg = pgit.length;

                              var objprocessed = 0;

                              if(pgitlg !=0)

                              {

                                  for(i=0; i<pgitlg; i++)

                                  {

                                      if(pgit[i].getElements()[0].constructor.name == "TextFrame")

                                      {

                                          var tfg = pgit[i].allGraphics;

                                          var tfglg = tfg.length;

                                          for(j=0; j<tfglg; j++)

                                          {

                                              var rec = tfg[j].parent;

                                              rec.anchoredObjectSettings.releaseAnchoredObject();

                                          }

                                      }

                                  }

                              }

                          }

                           

                          I have a file which i need to release from anchor, plz let me know how to share that file through our forum.

                           

                          thanks

                          • 10. Re: Release all anchored objects at once
                            csm_phil Level 4

                            Hi Pathi,

                             

                            i have tested the above js code its working fine, But still i dont know what is your expectations. Can you please provide the snapshot before and after.

                             

                            thx

                            csm_phil

                            • 11. Re: Release all anchored objects at once
                              Marc Autret Level 4

                              Try this:

                               

                              var a = app.activeDocument.allPageItems, t;
                              
                              while( t = a.pop() )
                                  {
                                  t.isValid &&
                                  t.hasOwnProperty('anchoredObjectSettings') &&
                                  (t.parent instanceof Character) &&
                                  (t=t.anchoredObjectSettings).isValid &&
                                  t.releaseAnchoredObject();
                                  }
                              

                               

                              @+

                              Marc

                              • 12. Re: Release all anchored objects at once
                                TᴀW Adobe Community Professional & MVP

                                Cute! But a little hard to debug!

                                 

                                Is it ok to rely on the order of the Javascript interpreter like that?

                                 

                                Ariel

                                • 13. Re: Release all anchored objects at once
                                  mr.pathi Level 1

                                  Hi CSM,

                                   

                                  Thanks for your effort in this, yah you are right its working good. But for some files it is not working.

                                   

                                  I would like to share that file with you all to test file. Plz let me know how to share that with this forum? or plz give me any email id and i will send you that file.

                                   

                                  Thanks

                                  • 14. Re: Release all anchored objects at once
                                    mr.pathi Level 1

                                    Hi Marc,

                                     

                                    Thanks, I will check and let u know...

                                     

                                    Thanks

                                    • 15. Re: Release all anchored objects at once
                                      mr.pathi Level 1

                                      Hi Marc,

                                       

                                      I was amazed, this is what i expected. Its working fine, thanks a lot. You saved me a lot of time and work....

                                       

                                      tks

                                      Thiru

                                      • 16. Re: Release all anchored objects at once
                                        mr.pathi Level 1

                                        Hi Marc,

                                         

                                        Could you suggest any tutorial (any website) to learn js from basic for InDesign, please? I dont have any background knowledge about programming...

                                         

                                        Tks in advance

                                        • 17. Re: Release all anchored objects at once
                                          rissbag

                                          Hi guys,

                                           

                                          Could some one please send me the .jsx file to release all anchors? I'm really struggling here, am new to scripting and can't figure it out! Or is there somewhere I can download it?

                                           

                                          Thanks so much

                                          • 18. Re: Release all anchored objects at once
                                            Larry G. Schneider Adobe Community Professional & MVP

                                            Copy the text in the white box in post #11. Use ESTK (ExtendScript Tool Kit) or any text editor and paste the text from above. Save the file as plain text with the .jsx extension. Place the file in HD/Applications/Adobe InDesignCSx/Scripts/Scripts Panel. Restart ID and with a file open, go tom menu Window>Utilities>Scripts and double-click on the script to run it.

                                            • 19. Re: Release all anchored objects at once
                                              [Jongware] Most Valuable Participant

                                              > .. Restart ID ..

                                               

                                              Not necessary at all to quit ID! As soon as you place a new script in the ascrts folder, you'll see it magically appear in the Scripts Panel. (Also, if you saved it at what you think was the right place and it does not appear, you used the wrong location.)

                                              • 20. Re: Release all anchored objects at once
                                                Larry G. Schneider Adobe Community Professional & MVP

                                                I guess I'm too used to AI which requires a restart to add the file to it's list.

                                                • 21. Re: Release all anchored objects at once
                                                  [Jongware] Most Valuable Participant

                                                  That explains it. :)

                                                   

                                                  I'd love to hear Adobe's explanation, though, about this stuff lagging behind in Illustrator, while the Script Panel and its behavior has been unchanged since *at least* CS, and probably before that as well. (For once that's actually a GOOD thing to leave exactly as it is!)

                                                  • 22. Re: Release all anchored objects at once
                                                    CreeDeaux Level 1

                                                    Wanted to add something to this old thread about the script to release all anchored objects.

                                                     

                                                    If you double click it and nothing happens, it may be because the objects are considered un-releasable by InDesign. Like if you click one and go to the anchored objects menu, the release option is grayed out. This may be a bug or have to do with grouping.

                                                     

                                                    You can fix it by clicking within the text box containing those objects, doing select all, and then going up to object - anchored object - Options. Then change the position dropdown to "Custom". At this point the objects may all collapse together since they no longer have their previous position settings... but they will now be allowed to release. At this point the script should work.