Releasing Anchors of the Anchored Objects VB Script

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Releasing Anchors of the Anchored Objects VB Script

Viewing 7 reply threads
  • Author
    Posts
    • #80662

      Friends,
      I require to release the Anchors of the Anchored Objects and keep it in the same place in the InDesign file. I am using CS6, Windows. I like to go for VB Script. Can anyone help please?
      Thank you in Advance.

    • #80663
      David Blatner
      Keymaster
    • #80665

      Hi David,
      Thank you for the quick response. I downloaded the script and ran it. It echoes the error “Please select an inline item”
      Any clues?

    • #80706

      Hi David,
      Sorry, I need to select the anchored object before running the script. I did not do and hence the issue.

      I selected the object and ran it. It worked fine. Thank you for that.

      Now, my InDesign file has some 800 pages and many pages have many objects. So, selecting them individually and running the script is a huge task. Is there anyway to automate the same too?

      I am using CS6 in Windows.

    • #80708
      David Blatner
      Keymaster

      I don’t know, sorry. Maybe this thread will help? https://forums.adobe.com/thread/932591

    • #80711

      Thank you David, It worked well.
      ^a is the key option.

    • #104497
      Ramy Romeoz
      Member

      Please
      How can I run this script ?!

      I opened notepad file and pasted this code in it and clicked save , closed the file

      opened it and went to file , save as , changed its extension to jsx

      Put it in C:\Program Files\Adobe\Adobe InDesign CC 2018\Scripts\Scripts Panel\Samples\JavaScript

      restarted indesign but the code don’t run

    • #104508
      Loic Aigon
      Member

      This might help given that you set the margins of the main thread and also set a specific object style (I like to report everything as possible on native and editable features) ;)

      ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

      var main = function() {

      var doc = app.properties.activeDocument, sel, docFile, m = $.os[0]==”M”,
      mf = function ( f ) {return (f instanceof Folder)||/\.docx?$/i.test(f.name)},
      wf = “Word files : *.doc, *.docx;”, filter = m? mf : wf;

      if ( !doc ) {
      alert(“You need an open document” );
      return;
      }

      if ( app.selection.length!=1 || !(app.selection[0] instanceof InsertionPoint) ) {
      alert(“Please select some insertionPoint and try again”);
      return;
      }

      docFile = File.openDialog(“Please open Word file…”, filter);
      if ( !docFile ) return;

      sel = app.selection[0];
      sel.place ( docFile );

      anchorAnswers ( doc );

      }

      function anchorAnswers ( doc ) {
      var fgp = app.findGrepPreferences.properties,
      cgp = app.changeGrepPreferences.properties,
      n = 0, found = [], nText, ip, anchored;

      app.findGrepPreferences = app.changeGrepPreferences = null;

      app.findGrepPreferences.properties = {
      findWhat:”#L.+\\r”,
      }

      found = doc.findGrep();
      n = found.length;
      while ( n– ) {
      nText = found[n];
      ip = nText.insertionPoints[0];
      anchored = ip.textFrames.add({geometricBounds:[0,0,60,60]});
      nText.move ( LocationOptions.AT_BEGINNING, anchored.parentStory.insertionPoints[0] );
      anchored.appliedObjectStyle = getObjectStyle (doc, “anchored” );
      }

      app.findGrepPreferences.properties = fgp;
      app.changeGrepPreferences.properties = cgp;
      }

      function getObjectStyle (doc, styleName ) {
      var st = doc.objectStyles.itemByName ( styleName );
      !st.isValid && st = doc.objectStyles.add ({name:styleName});
      return st;
      }

      var u;

      app.doScript ( “main()”,u,u,UndoModes.ENTIRE_SCRIPT, “The Script” );

      ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

      • #104547
        Loic Aigon
        Member

        Hello all, sorry for the submitted script. It was intended for another topic and landed here by mistake. I guess it was confusing to say the least.
        Unfortunately i can’t remove it from here :P

Viewing 7 reply threads
  • You must be logged in to reply to this topic.
>