Skip to main content
Inspiring
August 6, 2024
Answered

Overlapping Data Merge

  • August 6, 2024
  • 2 replies
  • 326 views

I am having trouble with variable-length data merges overlapping with each other.  It appears this is not a new thing, and was addressed (and solved) in this thread.  I have made a single text box formatted the way I would like.  The problem is that the script is not working for me.

 

The script should take the single-item merged documents and stitch them together.  When I run the script, I get the error "Error string: app is not defined."  I am a real beginner, so it's possible, I made a mistake with the script, but it was just a copy-paste thing... so I don't know.  I made a txt file with the .idjs extension with this as the text. 

function main(){
    var doc = app.documents.everyItem().getElements();
    var n = doc.length;
    if(!n){
        alert("You need a document");
        return;
    }
    doc = doc[0];
    var tfs = doc.pages.everyItem().textFrames.everyItem().getElements();
    n = tfs.length;
    while(n--){
        if(n==0) break;
        tfs[n].previousTextFrame = tfs[n-1];    
    }
}
var u;
app.doScript("main();", u, u, UndoModes.ENTIRE_SCRIPT, "Merge textframes");

But I get an error. 

 

Any help would be appreciated.

 

Thank you!

This topic has been closed for replies.
Correct answer m1b

Hi @Benjamin39010368auuu, it is an easy fix I hope. Just change the script's file extension to ".js" because the code is ExtendScript, not UXP.

- Mark

2 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
August 6, 2024

Hi @Benjamin39010368auuu, it is an easy fix I hope. Just change the script's file extension to ".js" because the code is ExtendScript, not UXP.

- Mark

Inspiring
August 6, 2024

Easy fix indeed! Thanks for the help!