(AS) Scripting Data Merge and ID (almost done)

All,

I have been able to create an new document, add a text box, a picture box and also brought in a .CSV file and have it show up in the Data Merge Pallet. It may not be pretty and could probably use some clean up, but it seems to work.

The problem I am having is getting the data merge categories placed into the rectangles that were created in the document.

Here is my code:

tell application "Adobe InDesign CS2"
activate
set myDocument to make document
tell myDocument
set myRectangletext to make rectangle with properties {geometric bounds:{"0 in ", "0 in ", "2 in ", "2 in "}}
set myRectanglepicture to make rectangle with properties {geometric bounds:{"0 in ", "0 in ", "3 in ", "3 in "}}
end tell
end tell

tell application "Adobe InDesign CS2"
set aDoc to active document
tell application "Finder"
set aFolder to "macintoshHD:Users:someuser:Desktop:"--you need to change the path
set aFile to ((aFolder as string) & "test.csv") as text
end tell
set dm to data merge 1 of aDoc
set p to properties of dm
tell data merge 1 of aDoc to select data source data source file aFile
end tell

and here is the Test.csv file I used:

testmerge,@testmerge2
1,2
3,4

I have been looking all over the web and cannot find any info on this and many unanswered questions - This may help many others.

Any help would be greatly appreciated.

Steve

This must either be a really difficult question or I am not explaining myself correctly. I have posted this question on 4 different forums for two days and have had lots of looks but not a single response.

Any help would be greatly appreciated.

Hi,

Did you try like this.


tell application "Adobe InDesign CS2"
activate
set aDoc to make document
tell aDoc
set myRectangletext to make rectangle with properties {geometric bounds:{"0 in ", "0 in ", "2 in ", "2 in "}}
set myRectanglepicture to make rectangle with properties {geometric bounds:{"0 in ", "0 in ", "3 in ", "3 in "}}
tell application "Finder" to set aFolder to "macintoshHD:Users:someuser:Desktop:"--you need to change the path
tell application "Finder" to set aFile to ((aFolder as string) & "test.csv") as text
set dm to data merge 1 of aDoc
set p to properties of dm
tell data merge 1 of aDoc to select data source data source file aFile
end tell
end tell

Thanks
Rajeev

Cleaner

Thanks Rajeev

From what I can see the problem is that you are not associating the data fields with the new text boxes in any way. From a quick look into the data merge, which I have not had much experience with, most of the properties that are associated with it are read only and cannot be set. It does not look like you can link up the data merge fields using a script, though I could be wrong here. I don’t know what you are using this for, but it might be easier to create a script that would do the same thing that you want the data merge to do or to switch over to just using the data merge and not using the hybrid solution.