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 188.8.131.52:
Though, I don't think, that much changed the last years with datamerge.
See some references below or search the API documentation for "datamerge":
Search the InDesign Scripting forum for datamerge.
One thread that came up with a search was:
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:
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.
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: