Highlighted

How "talk" to current page (selected in page-panel)

Explorer ,
May 27, 2020

Copy link to clipboard

Copied

Hallo,

I made script that makes several textframes on page.

However... script allways places the textframes on page one, regardless with page I select in page-panel.

I want: select page in page panel >> that wille be the page where textframe will be made.


Command I use now:

var myCurrPage = app.activeDocument;

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

var myCurrPage = app.activeWindow.activePage;

 

Note that you have to double click to make the page active in your window. 

 

You can also reference particular pages in your document with:

 

app.activeDocument.pages[index]; 

 

where [0] is the first page and so on, but this is not what you are after. app.activeDocument just returns the Document object. 

Topics

Scripting

Views

940

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How "talk" to current page (selected in page-panel)

Explorer ,
May 27, 2020

Copy link to clipboard

Copied

Hallo,

I made script that makes several textframes on page.

However... script allways places the textframes on page one, regardless with page I select in page-panel.

I want: select page in page panel >> that wille be the page where textframe will be made.


Command I use now:

var myCurrPage = app.activeDocument;

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

var myCurrPage = app.activeWindow.activePage;

 

Note that you have to double click to make the page active in your window. 

 

You can also reference particular pages in your document with:

 

app.activeDocument.pages[index]; 

 

where [0] is the first page and so on, but this is not what you are after. app.activeDocument just returns the Document object. 

Topics

Scripting

Views

941

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
May 27, 2020

Copy link to clipboard

Copied

var myCurrPage = app.activeWindow.activePage;

 

Note that you have to double click to make the page active in your window. 

 

You can also reference particular pages in your document with:

 

app.activeDocument.pages[index]; 

 

where [0] is the first page and so on, but this is not what you are after. app.activeDocument just returns the Document object. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
May 28, 2020

Copy link to clipboard

Copied

Hi Brian

 

Thanks... step by step I progress in learning to program in InDesign! a log way to go...!

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 27, 2020

Copy link to clipboard

Copied

Hi Jan,

select page in page panel is not possible out of the box.

There is nothing in the scripting DOM that would give you the pages that are selected in the Page panel.

You could get access to the active spread or the active page. But that could differ to the selection in the Pages panel.

 

To really get the selected page(s) in the Pages panel you need some tricks I developed about three years ago.

For InDesign CS6 only:

https://community.adobe.com/t5/indesign/active-page-vs-selected-page/m-p/8776563?profile.language=de...

 

For InDesign CC and above:

https://community.adobe.com/t5/indesign/active-page-vs-selected-page/m-p/8776565?profile.language=de...

 

Regards,
Uwe Laubender

( ACP )

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
May 28, 2020

Copy link to clipboard

Copied

Hi Uwe,

 

Thanks for reply... I think this stuff is for later, I have only been programming in InDesign for a week. I need small steps (ha ha).
But thanks anyway.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 28, 2020

Copy link to clipboard

Copied

Hi Jan,

the idea behind my procedure is very simple:

 

Use a menu command of the Pages panel to change the value of a property of a page you can later read out with:

doc.pages.everyItem().propertyname

 

Why does that work? That menu command would only work on selected pages in the Pages panel.

Unfortunately you need a menu command that, after it is executed, needs no further assistance.

 

For InDesign CS6 the best candidate was optionalPage.

With InDesign CS5, CS5.5, CC and above the only candidate left is pageColor.

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
May 28, 2020

Copy link to clipboard

Copied

Hi Uwe,

As far as I understand (your expanation):

- works only for the selected page

- I could use this command or setting to "identify" to witch page I am talking... (or labeling/numbering)

- but I can also use (other way): by using explicit pagenumber like: ...page(1) ..eg

Thanks,

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 29, 2020

Copy link to clipboard

Copied

Hi Jan,

you explicitely asked for this: "selected in page-panel".

Exactly that is the hard stuff.

 

To address a page in a document is very easy.

You can do it by its position in the document where counting starts with 0 :

app.documents[0].pages[3] // 4th page in the document

 

Or you can do it by name:

// WARNING: the same name could be used several times in one document.
app.documents[0].pages.itemByName("4") 

 

You could address the active page or the active spread.

But sometimes its surprising what InDesign thinks that is the active page or the active spread.

Do not trust your instincts as designer here.

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
May 29, 2020

Copy link to clipboard

Copied

@Uwe thanks...

you wrote: "you explicitely asked for this: "selected in page-panel"." >> you are right.

Beginners problem ... to not ask the right question. Maybe it will not be the last time?! .. sorry.

Regards,

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...