2 Replies Latest reply on Jul 22, 2015 3:17 PM by Colin Flashman

    IDCC2015 (MacOSX 10.9.5) Undefined is not an object when referencing dataMergeProperties.selectDataSource

    Colin Flashman Adobe Community Professional

      Hello everybody.


      I've been working on a script that works on an open InDesign file with data merge fields. When run, the script prompts the folder for a directory of text files, then a directory to put the resulting PDFs. It looks like this:


      #target indesign
      var myDoc = app.activeDocument;//the indesign file that is currently open  
      function main() {
           var f = Folder.selectDialog("Select the text files");
          var finished = Folder.selectDialog('select folder for finished PDFs').fsName + '/'; //selects a folder to put the finished files
          if (f == null) return;
          var files = f.getFiles();
          var imgs = new Array();
          var file, ext;
          for (var n = 0; n < files.length; n++) {
              file = decodeURI(files[n].name);
              ext = file.substring(file.lastIndexOf(".")+1,file.length);
              if ( ext == "txt" || ext == "csv" || ext == "TXT" || ext == "CSV") {       
                  imgs.push( file );
          for (var n = 0; n < imgs.length; n++) {
           var mergeTo = f.absoluteURI + '/' + imgs[n];   
           var pdfTo = finished + imgs[n] + '.pdf'
          myDoc.dataMergeProperties.exportFile(finished, "[High Quality Print]", );


      As I step through the script in debug in ESTK, everything looks fine until line 22 when I keep getting "undefined is not an object". But when I look at the data browser, everything looks like it should be where it is:


      Screen Shot 2015-07-22 at 9.02.02 pm.png

      My thoughts are that it has something to do with the filename referencing used by selectDataSource. But I have tried dozens of permutations of the filenaming using fsName, absoluteURI, and I really am stuck... and have been for some time. I've tried not to bother the forum, and I am sure that my coding should be correct, but clearly it isn't. Any pointers to solving this would be appreciated.