Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Set AppliedMaster to paragraph

Return to Member Forum

  • Author
    Posts
    • #75440
      Doug Morris
      Member

      I am using javascript and I have selected a paragraph. I would like to change the master on the page in which the paragraph resides, but I just cannot work out how to do it.

      To set the master I need something like app.activeWindow.activePage.appliedMaster=myNewMaster;
      That works fine. But how can I get a page object from a selected paragraph of text in a textframe? In other words how can I set the activePage?

      I have looked at the parent property and even whether I can “go to” the page with the text so that it is now the activePage, but just cannot find a solution.

      Any help very much appreciated, thanks.

    • #75448
      Ariel Walden
      Member

      Hi Doug,

      You don’t mention which version of InDesign you’re trying to get this to work on, and the method did slightly change at some point, but certainly from CS6 onwards, to find the page, you can do this:

      app.selection[0].parentTextFrames[0].parentPage

      However, this is slightly simplistic: for instance, if the text frame of the selected paragraph is sitting on the pasteboard, the above line will return Null.

      Likewise, you would need to check what happens if your text frame is in a table, footnote, etc.

      Learning to script InDesign is a very worthwhile exercise in my opinion. Nevertheless, if deadlines loom, etc., you may want to check out https://www.id-extras.com/products/mastermatic.

    • #75449
      Doug Morris
      Member

      Hi Ariel,

      That’s brilliant – exactly what I needed. I now realise the relationship between paragraphs and text frames, and between text frames and pages is the key to all this. It enables me to apply a master based on a specific paragraph style, and I can see that the website you pointed me to offers exactly that, so I’ll be checking it out.

      Many thanks, Doug.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
Forum Ads