1 Reply Latest reply on Jan 26, 2009 3:18 PM by (mps)

    Merging in InDesign

      Hi,
      Need help with javascript, trying to select a data source (.txt) to merge with indd. The merge fields are for an address block (two lines only) in a text frame, these will be the first two fields in the txt data source eg address1, address2. Trying to use - DataMergeFields.anyItem and selectDataSource, but can't get the function right.
        • 1. Re: Merging in InDesign
          Level 1
          Hi Yong Su Jun

          I am new to scripting but working hard at learning. The following snippet probably won't solve your need immediately but might help. It has worked for me so far but I haven't tested yet in the real world. This was pulled and modified from this forum. Maybe it will give you some ideas.

          var mydataMergeProperties = app.activeDocument.dataMergeProperties;
          var selectDataSource = "Data Merge: *.txt";
          var myDataSource = File.openDialog("your message here");
          app.activeDocument.dataMergeProperties.selectDataSource(myDataSource);
          app.activeDocument.dataMergeProperties.mergeRecords();

          This bit assumes that you want to have a dialog to browse to your data source, you could replace with the path.

          I hope this helps.