Copy link to clipboard
Copied
Hi all, I was wondering if anyone had advice regarding scripting buttons & bookmarks in Indesign.
For some reason when I try to create a "Go to destination" action on a button from a script - it only seems to work when the bookmark is from the same document. If I pass in a bookmark from another document, it still creates the action, but it will revert back to the first bookmark (alphabetically) of the active document - NOT the one I told it to go to. This is easy to do from the UI, and this code used to work for me, as I've built a whole fit-for-purpose custom script for a client that is based around being able to create buttons linking to bookmarks in other documents. But now this script has stopped working and I can't seem to diagnose why 😩
var _sel = app.activeDocument.selection[0]; var bookmark = app.documents[2].bookmarks[0].destination; //If bookmark is from another document, it will revert back to the first bookmark (alphabetically) of the active document //If the bookmark is from the active document, it works as expected _sel.gotoAnchorBehaviors.everyItem().remove(); var behavior = _sel.gotoAnchorBehaviors.add ( { behaviorEvent : BehaviorEvents.MOUSE_UP , enableBehavior : true , anchorItem : bookmark } );
Copy link to clipboard
Copied
"This is easy to do from the UI, and this code used to work for me, as I've built a whole fit-for-purpose custom script for a client that is based around being able to create buttons linking to bookmarks in other documents."
Hi Atlas.Murray,
if that's easy to do from the UI, I would do it from the UI and read out the properties and values from that button.
Perhaps this is solved in a different way than you thought? Or there other factors that must be met. Like the save status of the documents or something like that. Just guessing here…
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
> this code used to work for me
Which InDesign version was that? And which one do you (or your customer) use now?