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

Script to insert a paragraph after every table

Explorer ,
Feb 14, 2023 Feb 14, 2023

I want to add a paragraph after every table in my document, i was able to insert it before tables with this script but couldn't figure out how to insert it after tables, any help?

 

var tables = app.activeDocument.stories.everyItem().tables.everyItem().storyOffset
for (var i = 0; i < tables.length; i++) {
tables[i].contents = "\r";
}

TOPICS
Scripting
756
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

correct answers 1 Correct answer

Community Expert , Feb 14, 2023 Feb 14, 2023

Hi @ali u , Also if you want to add a paragraph after try this:

 

var ip = app.activeDocument.stories.everyItem().tables.everyItem().storyOffset;
var nl;
for (var i = 0; i < ip.length; i++) {
    nl = ip[i].index + 1
    ip[i].parent.insertionPoints[nl].contents = "\r";
}
Translate
Community Expert ,
Feb 14, 2023 Feb 14, 2023

I would apply a paragraph style with correct Space Before and Space After settings to the story offset insertion point. 

app.activeDocument.stories.everyItem().tables.everyItem().storyOffset
for (var i = 0; i < tables.length; i++) {
tables[i].applyParagraphStyle("nameofsryle");
}

 

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
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Hi @ali u , Also if you want to add a paragraph after try this:

 

var ip = app.activeDocument.stories.everyItem().tables.everyItem().storyOffset;
var nl;
for (var i = 0; i < ip.length; i++) {
    nl = ip[i].index + 1
    ip[i].parent.insertionPoints[nl].contents = "\r";
}
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
Explorer ,
Feb 14, 2023 Feb 14, 2023
LATEST

Thank you very much!

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