Skip navigation
drunk_irishman
Currently Being Moderated

Script a find/change using a datasource

May 8, 2012 9:16 AM

Tags: #indesign #variable_data #scriping

So I wrote a program (C#) a few years ago that basically opens an InDesign Exchange file, does a find/replace based on a SQL table datasourse and then our graphics folks would just convert the completed INX file back to InDesign and ultimately to a PDF.  Too many steps.

 

There are upwards of 2500 pieces of variable data in each file, so a product like DesignMerge is not practical.  Our data file basically consists of 2 fields [LookFor] and [ReplaceWith], I'd like an Indesign script that will just run through the data file and do a Find/Change for each record.  Is this doable and does anyone have any suggestions or starting points?

 

Thanks!

 
Replies
  • Currently Being Moderated
    May 9, 2012 6:09 AM   in reply to drunk_irishman

    Yes, it's possible. In my oppinion the easiest approach is to export your data to a csv-file and read it by script. I posted an example in this thread.

    However, on PC, it's also possible to exchange data directly between InDesign and Excel, or Access (without csv). I did some tests: the main (InDesign) part was written in JS. Another (Excel) part that opens a workbook, reads records and closes it was written in VB (it is sent from the main part via doScript method). The VB script reads all used ranges puts, them into a string and returns it back to the JS via ScriptArgs.SetValue method (JS gets the string by app.scriptArgs.getValue method).

     
    |
    Mark as:
  • Currently Being Moderated
    May 9, 2012 7:11 AM   in reply to drunk_irishman

    No, it doesn't matter which format to use: csv or tab delimited text format. Sure you can leave it as it is.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points