Highlighted

Release all anchored objects at once

Explorer ,
Dec 04, 2011

Copy link to clipboard

Copied

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

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

Topics

Scripting

Views

18.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Release all anchored objects at once

Explorer ,
Dec 04, 2011

Copy link to clipboard

Copied

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

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

Topics

Scripting

Views

18.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mentor ,
Dec 04, 2011

Copy link to clipboard

Copied

it seems your question already answered.

take a look here:

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 04, 2011

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Enthusiast ,
Dec 04, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 04, 2011

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Enthusiast ,
Dec 05, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 05, 2011

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mentor ,
Dec 05, 2011

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Enthusiast ,
Dec 05, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 05, 2011

Copy link to clipboard

Copied

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.getElements()[0].constructor.name == "TextFrame")

            {

                var tfg = pgit.allGraphics;

                var tfglg = tfg.length;

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

                {

                    var rec = tfg.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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Enthusiast ,
Dec 05, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guide ,
Dec 05, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 05, 2011

Copy link to clipboard

Copied

Cute! But a little hard to debug!

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

Ariel

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 05, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 05, 2011

Copy link to clipboard

Copied

Hi Marc,

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

Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 05, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 05, 2011

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Aug 16, 2012

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Aug 17, 2012

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Aug 17, 2012

Copy link to clipboard

Copied

> .. 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.)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Aug 17, 2012

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Aug 17, 2012

Copy link to clipboard

Copied

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!)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Oct 25, 2017

Copy link to clipboard

Copied

Hi Marc,

               how to Find Anchored text frames and objects

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Oct 25, 2017

Copy link to clipboard

Copied

hi

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Oct 25, 2017

Copy link to clipboard

Copied

HI csm

                 To add an Element and attribute as image in doc.Image is in Anchored text frame image also in Anchored ,I tried to add Indesign Quiet automatically.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Oct 26, 2017

Copy link to clipboard

Copied

Look at the dates of this thread. You are reviving a question thread that is nigh on 6 years old. (And with a relatively unrelated question as well.) Please observe proper netiquette and post new questions as new questions.

Also, if you tried to do so yourself: include what you tried, what didn't work, what error you got etc.

If you need a fully custom script written from scratch, and someone has the time to help you out for free, you're in luck. Else just hire someone.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Contributor ,
Jun 24, 2018

Copy link to clipboard

Copied

I suffer from this problem please

How can I put this script in indesign

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 biu the code don't run

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jun 25, 2018

Copy link to clipboard

Copied

Hi romeozzzzzzz ,

for using and installing ExtendScript scripts with InDesign see:

Indiscripts :: Indiscripts for Dummies

Just a note on the offered code here. Three things that can go wrong:

1. The anchored object is part of overset text. Released objects that are anchored in anchored objects could be removed.

2. The anchored object is anchored inline or anchored above line and method releaseAnchoredObject() will not work.

3. The anchored object released will not stay in position.*

* EDIT: When Inline and Above Line anchored object are duplicated and originals are removed as alternative to using method releaseAnchoredObject() that is only working with anchored anchored frames.

Regards,
Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Jan 12, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
mhjbnz LATEST
New Here ,
Jan 30, 2020

Copy link to clipboard

Copied

Here's my effort, building on Marc's work: https://gist.github.com/mhjb/5f78dee507754f0871891efe2c70d5ba

This script 'frees' & styles all anchored texts in a document, replacing anchors with the contained text

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...