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

This script for adding rows seems to be a bit off, please help fix it!

Advisor ,
Dec 25, 2024 Dec 25, 2024

Copy link to clipboard

Copied

This script is used to determine if there is already a table header and add a row if there isn't.

Since this script doesn't require the table to be selected in full, I like it.
I found the script to be correct if there is only one table.
However, if there are more than two tables, my cursor is already inside the second table, but mytable still points to the previous table table[0].

 

 

//first mytable in the active document
var mytable=app.activeDocument.textFrames[0].parentStory.tables[0]
var firstRow = mytable.rows[0];
//to header and add 1 row;
if (firstRow.rowType !== RowTypes.HEADER_ROW)
{
dupeTopRow(mytable);
mytable.rows.add(LocationOptions.BEFORE, mytable.rows[0]);
}
else{
alert("header exist")
exit ();
}

 

 

 

 

TOPICS
Bug , Feature request , How to , Scripting

Views

373

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
community guidelines
Community Expert ,
Dec 30, 2024 Dec 30, 2024

Copy link to clipboard

Copied

LATEST
quote

I suspect it looks for all text boxes, and every script in every text box.


By @dublove

 

Why would you think that? 

 

Votes

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
community guidelines
Community Expert ,
Dec 27, 2024 Dec 27, 2024

Copy link to clipboard

Copied

@dublove -- I've mentioned this before, and I'll mention it again, hoping that you'll add it to your list of New Year good intentions.

 

1. The most important thing for you is to get to grips with InDesign. Get yourself a good reference book. There are books aimed a users of various levels of experience. I would suggest Real-World InDesign. It covers InDesign up to some versions ago but nothing much has been added to InDesign in recent versions that would get people like you -- typesetters -- excited. It's an excellent reference with a good table of contents and an excellent index. You could also consider Linda tutorials, many of which are produced by seasoned InDesign pros.

 

2. When you can't find something in the book/tutorials, use a search engine to check whether your problem was dealt with in the past. You clearly don't do that. what you raised recently -- about user interaction -- is a sad example. User interaction has been dealt with many times in this forum but also in other forums.

 

3. Perhaps the best approach for you would be to hire a consultant. Make a deal with someone you can ask questions and ask to write scripts for you. You can learn from such a consultant, and you can also get some script solutions that are tailored to your problem. This is more efficient than trying to adapt other scripts to your needs.

 

P.

Votes

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
community guidelines
Advisor ,
Dec 27, 2024 Dec 27, 2024

Copy link to clipboard

Copied

The great Peter Kahrel.
You always give me some great ideas.


I'm just a typesetter and I'm pretty clueless about scripting.

I've actually searched through a lot of the postings and you'll see I've left comments under a lot of the old ones.

 

I'm making a lot of progress these days.
Thank you very much.

 

Just today I have completed a script worth millions.

I'll try not to ask big questions in the future.


It's all forced by life.

 

Congratulations on the fortune.
Thank you.

Votes

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
community guidelines