2 Replies Latest reply on Sep 18, 2008 2:52 AM by [Jongware]

    Bookmarks get wrong name

    Glen_Bal Level 1
      Hi all,

      In the archives i found that jongware had the same problem with bookmarks in CS3, but no solution. So here i am hoping for an answer.

      I have something like the following working code for adding my bookmark:
      h = app.activeDocument.hyperlinkTextDestinations.add(myPara);
      bm = app.activeDocument.bookmarks.add(h);
      bm.name = myString;

      When i make multiple bookmarks based on paragraphs the first bookmark ends up with the name "Anchor 1", the second one gets the correct name used in myString, the third one ens up with "Anchor 3", and so it goes on.

      What happens behind the scene:
      I start when i have 2 bookmarks. One with the name "Anchor 1" and the second is "myString for bookmark 2". I undo the rename and i get "Anchor 1" and "Anchor 2". Then i undo new bookmark and i get one bookmark "myString for bookmark 1". So i get the correct name.

      When i let the script run step by step in debug-mode i don't even see the name getting changed form "Anchor 1" to the string on any moment.

      Who comes up with the answer?

      (Javascript, Indesign CS3, Windows XP)

        • 1. Re: Bookmarks get wrong name
          Glen_Bal Level 1
          Ok, i found a solution.

          After adding the bookmark and before renaming you have the change your cursorposition (or something like that).

          bm.showBookmark(); did the trick for me.

          Stupid but it works.
          • 2. Re: Bookmarks get wrong name
            [Jongware] Most Valuable Participant
            I didn't add my own solution? I ended up adding a temporary bookmark immediately after the new one, then deleting it. That works as well.

            >Stupid but it works.

            Yep :-) Your method slightly less, tho'. It seems to me the bookmark needs to be "used" or "seen" in some way before a next change "takes". It positively wasn't like that in CS and CS2.