[JS CS3] Releasing Anchored Objects

Hello,
The following script places a libray item as an anchored object...
var myDoc = app.documents[0];
var myFrame = app.documents[0].textFrames.item("myTarget");
var myInsertPoint=myFrame.parentStory.paragraphs.item(0).insertionPoints.item(0)
var myLibraryItem=app.libraries[0].assets[0]; myFrame=myLibraryItem.placeAsset(myInsertPoint);
with(myFrame[0].anchoredObjectSettings){
anchoredPosition = AnchorPosition.anchored;
anchorPoint = AnchorPoint.topLeftAnchor;
horizontalReferencePoint = AnchoredRelativeTo.anchorLocation;
horizontalAlignment = HorizontalAlignment.leftAlign;
anchorXoffset = 0;
anchorYoffset = 0;
How do I now release my anchored library item and then send it behind the text in the text frame "myTarget" ?
Thanks
Simon Kemp

Thanks Harbs, this has made things simpler.
I have heard your name mentioned several times today in the InDesign Secrets podcast (and Dave's too).
I am almost there with the script (my scripting is clumsy but I can usually get things to work mainly with help from this forum.
My last problem is that I am re-applying geometric bounds to the released anchored object as it is still being referenced as myAnchoredFrame.
Is it possible to release ALL the anchored objects in one go? Or how do I dump the reference to myAnchoredFrame once it has been released?
var myTextFrame = app.documents[0].textFrames.item("myTarget");
var myParagraphs = myTextFrame.paragraphs
for (var i = 0; i <= myParagraphs.length-1; i++) {
var nLines = myParagraphs.item(i).lines.length;
var myAnchoredFrame = myTextFrame.paragraphs.item(i).insertionPoints.item(0).textFrames.add();
var myHeight = nLines*myParagraphs[i].leading*.353
myAnchoredFrame.geometricBounds = [0, 0, myHeight, (myTextFrame.geometricBounds[3]-myTextFrame.geometricBounds[1])];
myAnchoredFrame.fillColor = "Gradient";
myAnchoredFrame.gradientFillAngle = 90;
myTextFrame.texts.item(0).recompose;
with(myAnchoredFrame.anchoredObjectSettings){
anchoredPosition = AnchorPosition.anchored;
anchorPoint = AnchorPoint.topLeftAnchor;
horizontalReferencePoint = AnchoredRelativeTo.anchorLocation;
horizontalAlignment = HorizontalAlignment.leftAlign;
verticalReferencePoint = VerticallyRelativeTo.capheight;
verticalAlignment = VerticalAlignment.topAlign;
anchorXoffset = 0;
anchorYoffset = -1;
pinPosition = false
myAnchoredFrame.anchoredObjectSettings.releaseAnchoredObject ()
myAnchoredFrame.sendToBack();
Thanks again
Simon Kemp

Similar Messages

  • How to release Anchored objects in an .indd file

    I need to programaticaly release anchored objects in a opened indd file so that images's coordinates could get. does any one have an idea about how to do that.
    Thanks

    I need to programaticaly release anchored objects in a opened indd file so that images's coordinates could get. does any one have an idea about how to do that.
    Thanks

  • Releasing Anchored objects

    I saw a couple of earlier posts with code for releasing an anchored object ( http://forums.adobe.com/click.jspa?searchID=2331267&objectType=2&objectID=1109584 and http://forums.adobe.com/click.jspa?searchID=2331267&objectType=2&objectID=2062943 ) but I'm not sure how to make this work for my current situation, so would one of you folks give me a hand, please?
    I'm building a directory where business names are in one paragraph style that is a numbered list, but each of these paragraphs has anchored at the the beginning a frame containing proprietor names and phone numbers in other separate paragraph styles. I need to build an alphabetical index of stores and proprietors with the index number from the list. This actually isn't too hard to organize because I can set the numbered list style to start on next page, thereby making the list number and page number the same, but I need to release all the anchored objects so they don't get pulled in as part of the store name. I figure this should be pretty simple, so how about it? CS4, if it matters.
    Peter

    I didn't check the posts you mentioned, but I remembered there was a catch (an anchored object is identified only by having 'anchoredObjectSettings'). The extra try..catch surrounding the 'release' ought to shield you from oddities, as in "you can't release an anchored graphic".
    Other than that ... perhaps it's easier if you can select a text frame to release everything within? Or at once everything in the entire document?

  • Release Anchored Objects

    Hi,
    Does anyone knows about a scrip able to release all the anchored objects in a InDesign 5.5 document?
    Thank you in advance
    Maria

    Hi Maria,
    Please use the below JS code, But the code is your requirement has been solved, i feel this way is big round circle. So any one make short your requirement after my script to edit or modify.
    var myDoc = app.activeDocument;
    var myPGItem = myDoc.allPageItems;
    for(j=0; j<myPGItem.length; j++){
        var myAncObj = myPGItem[j];
        if(myAncObj.parent.constructor.name=="Character"){
            if(myAncObj.constructor.name =="TextFrame" || myAncObj.constructor.name =="Rectangle" || myAncObj.constructor.name =="Group"){
                myAncObj.anchoredObjectSettings.releaseAnchoredObject();
    thx
    csm_phil

  • CS3 - Auto Anchored objects

    Hi all,
    I would like to speed up my workflow enormously. I have a very repetitive thing that I need to speed up somehow...
    I receive supplied text that requires formatting. I have just about everything automated except inserting graphics into certain locations. I currently insert an object as an anchored object one by one wherever it needs to be put..
    The things is, all the graphic objects are identical (the exact same file), and they appear hundreds of time throughout the document.
    The objects are to all behave exactly the same way so a style could be set up - it's just the matter of placing the object hundreds of times every time I get new text to update the file with. So at the moment, I am spending way way way too much time individually placing each object one by one.
    I'm not a highly experienced ID user, so I'm hoping I'm just missing something here. I've scoured tutorials and help and the web to no avail. Hence my post here.
    Currently, they put the text code "grphc" where they want the little picture in the text supplied to me. I then do a search for "grphc" in the find function. It finds it, I then select this code and place the inline object. I then go back to the find function to show me the next code. It takes me straight to it, I then repeat the process of selecting the text code, place the object, find the next code, select the code, place the object, find the next code, select the text, place the object, find the next code, select it, place the thing, find the next, select it, place it... and so on and so on till my brain hurts through a very very repetitive operation. It hurts!.
    Please help me automate this very time consuming and brain numbing repetitive action...
    Like I said, I'm not a heavily experienced user of InDesign, so I'm hoping that I am simply missing something. (I can only hope)
    I'm hoping that a very easy, almost 'one click' fix can replace the special code with this little grpahic.
    I mean, I can find all occurrences of a given text in the document and replace it all in one hit with some other text, but it seems to not allow to replace text with a graphic.
    please help. even if the answer is in front of my face & cannot see it..
    Thanks very much in advance.
    Graeme.

    WOW!!!,
    Thankyou Dave, that works a treat.
    I must admit though, I am surprised that with the amount of power ID has with this Find/Replace function that it doesn't have the ability to find and replace with a graphic.
    Maybe I should put a wish list to ID to add this find text and replace with an object feature...
    Graeme.

  • [JS][CS3-CS5] anchored objects/inline back to text

    g'day there.
    been handed a reformatting job where the client has supplied text in word with additional textframes (they have made callouts next to their body text), meaning when the text is imported into indesign, the text has hundreds of anchored objects containing the callouts. is it possible to take these anchored objects and convert them back into the actual main textframe? ATM, the only way to do this would be to cut and paste.
    i have done a search on the forums and elsewhere to remedy this and there are plenty of threads advising on how to take text and make anchored objects out of them, but what i want to do is the reverse.
    thank you.
    colly

    i feel strange answering my own question, but i stumbled across this older applescript and it seemed to do the trick, so thought i'd put it out there.
    tell application "InDesign CS5"
        tell document 1
          set thetextframes to text frames
          repeat with aframe in thetextframes
             set theCount to count of (text frames of aframe)
             tell aframe
                 repeat with i from theCount to 1 by -1
                   set boxContents to paragraphs of text frame i of aframe as string
                   set contents of first insertion point of parent of text frame i to boxContents
                   delete text frame i of aframe
                 end repeat
             end tell
          end repeat
       end tell
    end tell
    full credit to peter kincaid who wrote the script. all i did to make it work was just to tell the application CS5 rather than CS1 which was in the original script.
    the actual site i found the script at was:
    http://olivier.berquin.free.fr/indesign/indesign_cs1.html

  • Release Anchor for grouped object

    Hi All
    How to release the Anchored object that has group of objects, Is there any property to find the anchored object with group. I need to find those anchored object with group and release the anchor, if the object is placed as inline I can find other anchor objects without group but not the one with group. How to find and release those objects through script?
    thanks
    Jason

    Hi Jason,
    About releasing anchored objects, a generic routine has been given here:
    http://forums.adobe.com/message/4062574#4062574
    Here is a slight adjustment that only targets groups:
    var a = app.activeDocument.allPageItems,
        t;
    while( t = a.pop() )
        t.isValid &&
        (t instanceof Group) &&
        (t.parent instanceof Character) &&
        (t=t.anchoredObjectSettings).isValid &&
        t.releaseAnchoredObject();
    @+
    Marc

  • Release all anchored objects at once

    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

    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

  • Anchored objects and first line in InDesign CS3

    Hi, thanks for reading. I know that when you want an achored object at the beginning of a text block to all push away ("wrap around") the text, including the first line, you have to put it into a line before that.
    What I don't like about it, is that I then have an empty first line and everything else is pushed one line down. Now I could move the whole textbox up, to fit to the rest of my layout, but that's not the way one should work in InDesign. Is there a way to get around the first line?

    T-
    Select the anchored object and put text wrap on it. Then select the anchored object and go to Object/Anchored Object/Options. Select Position: Inline and set the Y Offset to the negative number that aligns your text where you want it.

  • [CS3] GREP-Problem with Anchored Objects

    Hi,
    I've the following problem:
    Lines beginning with a, b, c etc. should be formatted equally, so I use the following GREP:
    Search:
    ^([a-z])(\.??)([ \t])
    Replace:
    $1.\t
    Now there are some abc lines, which begin with an anchored object, so I tried:
    Search:
    ^(~a*?[a-z])(\.??)([ \t])
    Replace:
    $1.\t
    But with this, the anchored object is deleted. Is this a bug or am I doing something wrong?
    Thanks
    Tobias

    That's a known bug -- Dave Saunders discovered it, to his surprise, I might add. There seems to be no reason for it.

  • Anchored Objects Disappear When Page Moved

    I'm working in InDesign CS2 in XP environment. I duplicated a page that contains anchored objects. It was page one; the duplicate page is now page 5. I modified the duplicate page 5. Now I want the altered page 5 moved into page 1 position.
    When I move the pages either by dragging or by right clicking on the page icon and using the Move Page command, all anchored objects on the page disappear. I also cannot release the anchored objects because the release command is disabled when I select an object with the selection tool.
    Any suggestions?

    I got your file, and after looking at it, it's probably better not to post it publicly. For the lurkers, it's a draft government document, not yet ready for release.
    Anyway, I took a look at the file, first in CS2 where it was created, and then in CS3 to see if it would behave differently.
    First, the anchored objects aren't really gone, just temporarily invisible. if you select the objects and move the page, you can still see the selection outline. It's some sort of screen display bug/glitch, I think, in CS2. Exporting to .inx didn't fix it, so I think it's not corruption, and it doesn't happen at all in CS3.
    The bad news is I have no way to explain what the problem is, or how to prevent it from happening. The good news is I found a way to make them reappear! Select the text frame with the selection tool, and change its stacking order. I tried Ctrl + Shift + [ to send to the back, and Ctrl + ] to bring forward, and both seemed to work, though it may make a difference where in the order they start out. If one attempt doesn't work, try again, or send all the way back or forward.
    For what it's worth, this is only a display problem. Even when the anchored objects are not visible on the screen they show in both printed and exported PDF.
    Peter

  • CS4 text wrap over anchored object

    Every time I place an anchored object (doesn't matter if it's graphic or text frame) and apply text wrap, Indesign freezes permanently and only solution is killing it via task manager.
    I opened CS3 file with anchored objects w/ txt wrap and the same freeze happens when trying to move, delete or apply different wrap settings to object.
    It never happened in previous version of ID on my machine.
    Any solution to this problem? Thanks.
    My PC conf.:
    AMD x2 2.7
    2GB RAM
    Vista 32bit

    The first thing to try is replacing your preferences.
    http://livedocs.adobe.com/en_US/InDesign/5.0/help.html?content=WSa285fff53dea4f86173837510 01ea8cb3f-6d1e.html

  • Anchored objects behind text

    Is there a way to make an anchored box sit behind text? I have a section title with section numbers. I would like to place a piece of art behind all the section numbers. The box always comes out on top. I can create a new paragraph style with autonumbering for the section into it, place it over the art, group it, and then anchor it. The only problem is, now the section numbers won't show up in the running head. Any ideas? I'm using CS3. I used to be able to do this in FrameMaker. Thanks.

    Can't be done with anchored objects - sorry.
    But you can convert your text to a table - and that can put a background in there.
    OR
    Use Paragraph Rules to highlight a line of text or a pargraph of text
    http://www.theindesigner.com/blog/episode-49-paragraph-rules-rule

  • My anchored objects dont display after CS5 upgrade - help?

    Hi,
    We've just upgraded to CS5 from CS3.
    I publish educational books, which contain a lot of object styles and anchored objects.
    I have just opend a book im working on in CS5 and have had problems with both anchored objects not displaying and object styles changing. The first is more pressing.
    The problem arises where I have an anchored object inside another anchored object, and they use custom positioning.
    For example. I have a pullout box that contains text and an image. The image is anchored inside the pullout box and the pullout box is anchored to the main body of text.
    The images are no longer displaying. I can select their frames, and if i change the image positioning to inline the images display fine, but when it is set to custom (which they need to be) I can no longer see the image.
    Is anyone able to help with this, its a major problem as i am woking with hundreds of images here.
    Thanks

    My usual advice is that with a project this large, it's best to finish it in the same version it was started in. Even a small change in the text engine can effect things like this and there were changes from CS3 to CS4 and again to CS5, but I'm not really sure what's happening in your case.
    Bob

  • Anchored objects are transparent

    Thanks in advance for the help. I am using CS5.
    I have a document were multiple anchored objects ended up overlapping each other. My problem is that the anchored objects have a transparency set to them that I cannot remove. Things to note:
    The transparency goes away if I release the anchored object.
    I have an object style assigned to the anchored frames, but there are style overrides that I cannot clear on the anchored objects.
    Changes I make to the object style assigned to the anchored objects have no effect. Only the "anchored objects options" attributes box will modify the anchored objects.
    Any help with this issue would be great. Thanks!

    You Sir, are an absolute genious! It makes absolute and perfect sence, but I guess that's what they mean by "Hindsight is 20/20."
    Thanks again!

Maybe you are looking for