Can't figure out apple script for a simple merge task

Community Beginner ,
Mar 04, 2021 Mar 04, 2021

Copy link to clipboard

Copied

I've only dabbled with modifying existing scripts, but I'm trying to write one for doing what should be a pretty simple merge task.
But I can't get this to work, I keep getting this unhelpful error: 'Adobe InDesign 2021 got an error: Can’t continue merge records.' I've stripped down my csv file and indesign doc to make them as simple as possible. Can someone point me to what I'm missing? 

 

 

tell application "Adobe InDesign 2021"
activate
set csvPath to "{filepath here}:TestCSV.csv"
set docPath to "{filepath here}:TestMergeDoc.indd"
set user interaction level of script preferences to never interact
set myDoc to open docPath
set dataMerge to data merge 1 of myDoc
select data source of dataMerge data source file csvPath
tell data merge properties of myDoc
tell data merge preferences
set record selection to all records
set records per page to single record
end tell
end tell
merge records

 

 

TOPICS
Scripting

Views

59

Likes

translate

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

Adobe Community Professional , Mar 05, 2021 Mar 05, 2021
  Tell blocks always need to be closed with an end tell, and merge records would need to be inside of tell data merge properties of myDoc.   Also, you probably want to wrap merge records in a try block—in case there’s nothing to merge. And be careful with set user interaction..., if you set it to never, you would need to set it back to always at the end of the script or on an error.   tell application id "com.adobe.indesign" activate set csvPath to "{filepath here}:TestCSV.csv" set docPath ...

Likes

translate

Translate

Translate
Enthusiast ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

Hello Glen,

 

I don't know Apple script very well, take a look at the link below to see if it helps you.

https://macscripter.net/viewtopic.php?id=18729

 

I have a javascript that appears to be doing the same thing you're trying to......

if you're interested I'll post it..

 

Regards,

Mike

Likes

translate

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
Adobe Community Professional ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

 

Tell blocks always need to be closed with an end tell, and merge records would need to be inside of tell data merge properties of myDoc.

 

Also, you probably want to wrap merge records in a try block—in case there’s nothing to merge. And be careful with set user interaction..., if you set it to never, you would need to set it back to always at the end of the script or on an error.

 

tell application id "com.adobe.indesign"
	activate	
	set csvPath to "{filepath here}:TestCSV.csv"	
	set docPath to "{filepath here}:TestMergeDoc.indd"	
	--set user interaction level of script preferences to never interact	
	set myDoc to open docPath	
	set dataMerge to data merge 1 of myDoc	
	select data source of dataMerge data source file csvPath	
	tell data merge properties of myDoc		
		tell data merge preferences			
			set record selection to all records			
			set records per page to single record			
		end tell		
		try			
			merge records			
		on error			
			--do something			
		end try		
	end tell	
end tell

 

 

 

 

Likes

translate

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 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Ah, that's exactly what my problem was, thanks for the explanation!

Likes

translate

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