• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Open file(s), toggle Data Merge Records, Export

Community Beginner ,
Mar 24, 2017 Mar 24, 2017

Copy link to clipboard

Copied

Hello,

I've read through the developer guides and can't find any language about Data Merge exports.

What I'm looking to accomplish should be a rather simple script. The pieces I haven't been able to track down are in bold below.

1. Open file

2. Select Data Merge Source

3. For each

     a. Toggle Data Merge

     b. Save as InDesign file (name defined by column 1 in data merge underlying file)

     c. Export to PDF (name defined by column 1 in data merge underlying file)

4. Next

5. Close file

// defines the csv file to use for dataMerge

var csvFile = File('filepath');

// defines the csv file to use for dataMerge

var exportLocation = File('filepath');

// opens InDesign template

app.open(File("filepath"));

//defines myDoc

var myDoc = app.activeDocument

// loads defined csv file as datamerge

app.activeDocument.dataMergeProperties.selectDataSource(csvFile,);

//runs loop

For each //datamerge record

//preview

//save as indesign

//export as pdf

Next

Would appreciate any help or thoughts on this. Thank you.

TOPICS
Scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 27, 2017 Mar 27, 2017

Sorry, i cannot help with the vbs side of scripting.


Perhaps you don't know, but one is able to execute vbs code with InDesign ExtendScript's doScript() method.

Search for doScript() in the forum here. Also see this post here where Excel is called by vbs using ExtendScript:

Re: How do you run VB from JSX and return a value?

Regards,
Uwe

Votes

Translate

Translate
Community Expert ,
Mar 25, 2017 Mar 25, 2017

Copy link to clipboard

Copied

Hi,

a moderator moved your question to the InDesign Scripting forum.

What is your InDesign version on what OS ?

Are you aware, that there is ExtendScript DOM documentation for nearly all InDesign versions?

Here one Gregor Fellenz compiled for CC 2017 12.0.0.81:

InDesign ExtendScript API (12.0)

Though, I don't think, that much changed the last years with datamerge.

See some references below or search the API documentation for "datamerge":

DataMergePreference

InDesign ExtendScript API (12.0)

DataMergeOption

InDesign ExtendScript API (12.0)

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2017 Mar 25, 2017

Copy link to clipboard

Copied

Search the InDesign Scripting forum for datamerge.

One thread that came up with a search was:

DataMerge preview

It seems, that Preview is not scriptable by DOM objects directly.

And I remember that Preview should be avoided before a merge, because the function has a bug.

Also search for that in the InDesign forum.

FWIW: Maybe Preview for datamerge is scriptable by invoking the right menuAction in the UI, but as I mentioned above, this could perhaps spoil your merged results.

What do you exactly mean by: "toggle Data Merge Records" ?

Can you show some screenshots perhaps?
Do that with the forum's "Insert Image" control in the editor bar:

InsertInlineImage-ScreenCapture-AdobeForums.png

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Thank you for the insight on the DOM documentation. I am going to be writing this in vbs so I can get better integration with Excel, where all of the source data is pulling from.

I've realized I don't need to preview the datamerge, and rather need to utilize the Create Merged Document capability of InDesign, restricting to a Single Record in my For Each loop.

It seems there is a lot more documentation on jsx than vbs for things of this nature. Any direction on where to look for the datamerge option coding for vbs?

Here is what I would need it to do.

'sets InDesign

Set myInDesign = CreateObject("filepath")

'sets myDocument

Set myDocument = myInDesign.Open("filepath")

'loads defined csv file as datamerge 

myDocument.dataMergeProperties.selectDataSource(csvFile,);

For Each [record in datamerge]

    'create merged document on record i+1

    unknown

    'sets myDocument

    Set dmDocument = myInDesign.activeDocument

    'save as new filename

    dmDocument.Save "filepath pulled from row 1 of datamerge"

    export as pdf

    dmDocument.Export idExportFormat.idPDFType, "filepath pulled from row 1 of datamerge",

    False, myInDesign.PDFExportPresets.Item("[preset]")

Next

Again, big thanks for any tips or direction. Very appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Sorry, i cannot help with the vbs side of scripting.


Perhaps you don't know, but one is able to execute vbs code with InDesign ExtendScript's doScript() method.

Search for doScript() in the forum here. Also see this post here where Excel is called by vbs using ExtendScript:

Re: How do you run VB from JSX and return a value?

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

LATEST

You can get all data from excel, as array, using this function Get data directly from Excel

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines