Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Change Row-type

Engaged ,
Apr 04, 2017 Apr 04, 2017

Hello everybody.

It is really a simple thing. And for me it makes sense like I wrote that script. Unfortunatly: it does not work . Where is my error in reasoning?

...

if (myTables.rows.firstItem().rowType == RowTypes.BODY_ROW) {

     myTables.rows[0].rowType = RowTypes.HEADER_ROW; )

}

if (myTables.rows[-1].rowType == RowTypes.BODY_ROW) {

     myTables.rows[-1].rowType = RowTypes.FOOTER_ROW;

...

Nothing will be detected betweeen the parantheses. --> The condition has no function. There is no error-message too.

TOPICS
Scripting
363
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 04, 2017 Apr 04, 2017

I see only one problem in your code: the line 2 has a closing round bracket at the end.

Otherwise it works for me on my InDesign CC 2015 for Mac.

main();

function main() {

    var myTables = app.selection[0]; // Let's assume a table is selected

   

    if (myTables.rows[0].rowType == RowTypes.BODY_ROW) {  

         myTables.rows[0].rowType = RowTypes.HEADER_ROW; 

    }  

    if (myTables.rows[-1].rowType == RowTypes.BODY_ROW) {  

         myTables.rows[-1].rowType = RowTypes.FOOTER_ROW;  

    }

}

Also, I recommend you to use rows[0] instead of rows.firstItem() because it's faster.

— Kas

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 04, 2017 Apr 04, 2017
LATEST

If you have a cell selected then the following code works

myTables = app.selection[0].parent;

if (myTables.rows[0].rowType == RowTypes.BODY_ROW) {  

     myTables.rows[0].rowType = RowTypes.HEADER_ROW;  

}  

if (myTables.rows[-1].rowType == RowTypes.BODY_ROW) {  

     myTables.rows[-1].rowType = RowTypes.FOOTER_ROW;  

}

Check that your "myTables" is really a table, alert(myTables)

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