Skip to main content
Participating Frequently
February 23, 2023
Answered

Jump to pages

  • February 23, 2023
  • 2 replies
  • 1859 views

I have multiple master pages that have other master pages applied to some of them. I'd like to jump to the first document page that has been applied the current active master page. For example, I have a master page Project AB that has the master page A applied to it, and I have a document page '1' that has Project AB applied to the document page '1'. When I'm on master page Project AB, I want to jump to page '1'. Could this be achieviable via script? I've seen the other ways but not this way.

This topic has been closed for replies.
Correct answer m1b

Hi @Rachel28371239g14w, please try this script:

var doc = app.activeDocument,
    activeSpread = doc.layoutWindows[0].activeSpread,
    spreads = doc.spreads;

if (activeSpread.constructor.name == 'MasterSpread') {
    for (var i = 0; i < spreads.length; i++) {
        if (spreads[i].appliedMaster === activeSpread) {
            doc.layoutWindows[0].activeSpread = spreads[i];
            break;
        }
    }
}

If it works they way you want, you could assign a keyboard shortcut to it.

- Mark

2 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
February 23, 2023

Hi @Rachel28371239g14w, please try this script:

var doc = app.activeDocument,
    activeSpread = doc.layoutWindows[0].activeSpread,
    spreads = doc.spreads;

if (activeSpread.constructor.name == 'MasterSpread') {
    for (var i = 0; i < spreads.length; i++) {
        if (spreads[i].appliedMaster === activeSpread) {
            doc.layoutWindows[0].activeSpread = spreads[i];
            break;
        }
    }
}

If it works they way you want, you could assign a keyboard shortcut to it.

- Mark

Participating Frequently
February 23, 2023

This is fantastic! Just wondering if it's possible to make it applicable to those masters that have other masters applied to it? For instance, I have a master C that have master B applied to it, and master B has master A applied to it.

m1b
Community Expert
Community Expert
February 23, 2023

No, sorry about the confusion! Your script works exactly the way I wanted. It's just that if the AB-Master has another master page applied to it, let's say C, it jumps correctly to page 1 which has AB applied to page 1. But, it won't jump to page 1 if C also has another master BG applied to it. So, it currently only works if the master AB has only one other master applied to it, but I have BG -> C -> AB applied in this order and it only jumps if C -> AB. If that makes sense!


Sorry @Rachel28371239g14w, I'm still having trouble understanding! Could you please set up a little sample document, with the master pages that you want to be able to handle, and a bunch of pages with different masters applied, and post that .indd file here for me to look at, and also post a list of, for example:

 

A-Master should go to page 1

B-Master should go to page 3

AB-Master should go to page 2

C-Master should go to page 2

etc.

 

This will help me a lot! 🙂

- Mark

Robert at ID-Tasker
Legend
February 23, 2023

Yes, easy, but I'm not fluent in JS, so you need to wait for someone else 😞