Skip navigation
Alicia ALD
Currently Being Moderated

Keep layout position when using Find/Change?

Feb 14, 2013 8:18 AM

When using Find/Change in InDesign CS4, each occurrence of the "Found" material is centered in the window, so the page moves around with each find. Is there a way to keep the page in a fixed position when searching through a document?

  • Currently Being Moderated
    Feb 14, 2013 8:35 AM   in reply to Alicia ALD

    No. The behavior you are describing is a "feature" with no options.

    Mark as:
  • Currently Being Moderated
    Feb 14, 2013 3:47 PM   in reply to Alicia ALD

    Hi Alicia,


    What specifically would you like to happen? How about if, for instance,

    the entire spread is displayed each time you jump from one find to the next?



    Mark as:
  • Currently Being Moderated
    Feb 15, 2013 7:01 AM   in reply to Alicia ALD

    Hi Alicia,


    I don't have much time right now, so I'm going to try and post the

    following script via the email interface. In the past, this has caused

    the script to become mangled and not work, but that hasn't been

    happening recently, so maybe the forum software has been fixed. If it

    doesn't work, I will get back to it after Shabbat (the Jewish Sabbath).


    Run the script once, and InDesign will always try and keep the spread

    displayed (not just for find change, but any time the selection of

    anything changes). Run the script again to revert to the regular behaviour.


    The script does take up some resources, I think, so could be some things

    will run slower, don't know. I haven't noticed any adverse effects, but

    it's a little experimental!


    Anyway, here it is:


    #targetengine foo1

    var myEName = "Always show spread";

    var myFound = false;

    for (var a = app.eventListeners.length-1; a>=0; a--){

         if (app.eventListeners[a].name == myEName){


             myFound = true;



    if (!myFound){

         var myEvent = app.addEventListener("afterSelectionChanged",

 = myEName;



    Hope it helps!



    Mark as:
  • Currently Being Moderated
    Feb 19, 2013 9:04 AM   in reply to Alicia ALD

    Hi Alicia,


    What you did is what needs to be done. Unfortunately, the script won't

    work on CS4 (I just tried it myself and got the same error you do). (It

    uses an eventListener which didn't exist then, yet).


    It does work on CS6. Don't know about CS5.





    Mark as:
  • Currently Being Moderated
    Feb 19, 2013 10:01 AM   in reply to [Ariel]

    @Arïel – "afterSelectionChanged" is exclusively InDesign CS6.

    To achieve something like this in InDesign CS4, I think we have to rebuild the "whole" UI for search/replace as a custom palette window, list the found texts (in a scrollable sub-window?)  so that the user can click at a found item to navigate to (or uses controls like: "select", "next item", "previous item").


    The last part (the easy one), once the user clicked the found item in the UI controls of the custom palette, would be to select the particular text item and zoom the active window to spread wide.


    Here a snippet for the last, the easy part:


    if (myFoundText != null){, SelectionOptions.REPLACE_WITH);    


    However, I have left out the hard part ;-)


    So, @Alicia, this snippet is not working for you!
    It's just part of my outlined solution strategy…



    Mark as:
  • Currently Being Moderated
    Feb 19, 2013 12:10 PM   in reply to Laubender

    Actually, I can think of a shortcut for the hard part: The user uses the

    regular find/change UI to make all their settings. Then, they run the

    script, which will simply use the settings in the UI. Nice, huh! So you

    could get a listBox of all the finds -- select the entry and you get

    taken to the desired location. Click the "change" button and the change

    is made. Here's a proof of concept:


    #targetengine engine20

    var myFinds = app.findText();

    var w = new Window("palette");

    var myList = w.add("listbox", undefined, myFinds);

    var changeButton = w.add("button", undefined, "Change");

    myList.onChange = gotoFound;

    changeButton.onClick = makeTheChange;;


    function gotoFound(){[myList.selection.index].parentTextFrames[0].parent. parent);



    function makeTheChange(){




    Obviously very rudimentary: but this does work in CS4. If the list is

    too long, though, the change button will disappear off the bottom of the

    screen. Also, really once the change is made, the item should be removed

    from the list, but there's a bug in CS4 that makes it impossible to do

    that simply, if I recall correctly (or was that only a tree list?)


    Also, I have found that the only sure way of getting the entire spread

    to show is as I've done it above (and it would need much more error

    checking than this -- for instance, overset text).



    Mark as:
  • Currently Being Moderated
    Feb 19, 2013 1:33 PM   in reply to [Ariel]

    @Arïel – wow! Congratulations!
    This is very, very cool!!



    I can see some possible enhancements:

    An additional button: "Select only"


    A field where the user can input a value as zoom percentage to the found item with a couple of predefined values like "Fit page in window" or "Fit spread in window" or "100%" or "200"…


    And of course, other than listing the found objects as "[object Word]" or [object StyleRange] etc.etc. (that depends on the specific search), we could depict the "contents" of the found items together with their page names or numbers!


    I am excited!!



    Mark as:
  • Currently Being Moderated
    Feb 19, 2013 2:00 PM   in reply to Laubender

    Thanks. Yes -- it's rife with potential...


    It should probably have an option for find text and find GREP also.

    Maybe a couple of radio buttons or something.



    Mark as:
  • Currently Being Moderated
    Feb 19, 2013 2:20 PM   in reply to [Ariel]

    And "Sorting by Page", "This Page Only" etc…


    Something to sleep over (It's 11:20pm here in my part of the world) :-)



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points