Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Can't get to add the data merge text placeholder to all the text frames on the document

$
0
0

Hi,

 

So check this modification (replace for...loop)

var countFrames= 0, currLabel, capPerPage; for (i=0; i<myDocument.pages.length; i++){  // TOTAL NUMBER OF PAGES IN DOCUMENT          for(x = 0; x <  myDocument.pages[i].textFrames.length; x++){  //COUNT TOTAL TEXT FRAMES PER PAGE                    currLabel = myDocument.pages[i].textFrames[x].label;          // current textFrame label                    if(myDocument.pages[i].textFrames[x].label.search("caption") < 0)                              continue;                    else{                              capPerPage = Number(currLabel.match(/\d+/)[0]);          //          current label number value                              var captionString = 'caption'+(countFrames + capPerPage);          // recalculated to find proper placeholder                              var myTextFrame = myDocument.pages[i].textFrames[x];                              var myStory = myTextFrame.parentStory;                              var myStoryOffset = myTextFrame.parentStory.insertionPoints[-1];                              var myNamePlaceHolder = myDocument.dataMergeTextPlaceholders.add(myStory, myStoryOffset, get_field(captionString, myDocument)); // ADD DATA MERGE TEXT HOLDER TO TEXT FRAME                          }        }          countFrames += x; // INCREASE COUNT TO ADD frames found on previous pages}

 

Notice countFrames starts from 0.

 

Jarek


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>