• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Indesign data merge
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Indesign data merge


  • Subject: Re: Indesign data merge
  • From: Paul Abney <email@hidden>
  • Date: Mon, 18 Jul 2011 14:22:25 -0500

Wayne,
Thanks for the suggestions, but neither one seems to work. The record range does not seem to ever get updated when changing to a new data file unless a full merge completes using the new data, which does not help me.

So I have been working on a half binary search to find the correct data records. I found that if I try to set the record to use to a number higher than the new database has records I do get an error. So this is what I have come up with to try and get the record count:

set MyGuess to 20000
set StepBy to MyGuess
set TheDirection to "Up"

repeat until StepBy is 1
-- now we need to reset the direction and half the step
set TheDirection to "Up"
set StepBy to (round (StepBy / 2) rounding up)
tell application "Adobe InDesign CS5"
set myoriginal to document 1
tell data merge properties of myoriginal
tell data merge preferences
set record selection to one record
try
set record number to MyGuess
on error
set TheDirection to "Down"
end try
end tell
end tell
-- if the direction is still Up then we need to guess a higher number
-- if the direction has changed to down we need to guess a lower number
if TheDirection is "down" then
set MyGuess to (MyGuess - StepBy)
else
if StepBy is 1 then -- we have found our number
else -- set new step
set MyGuess to (MyGuess + StepBy)
end if
end if
-- if we ever go below 1 then there is no data in the indy file
if MyGuess is less than 1 then
set MyGuess to 0
end if

end tell
end repeat

return MyGuess

This is my first try at something like this, so I am sure that it made more simple. Also this works fine IF I have an even number for records. If my records are an odd number I am off by one. Not sure what I am doing wrong, or how to fix it, but I'm getting close.
If any one has any tips I would love to hear them.


Paul


On Jul 15, 2011, at 12:33 AM, Wayne Melrose wrote:


On 14. juli 2011, at 21.28, Paul Abney wrote:

I am looking for a reliable way to get the record count for an indesign data merge. The idea is to set up the merge fields in indesign, then my script will step through each record and create an individual indesign file as well as a pdf and name the files from an appropriate data field in the merge. This is a snippet of what I have:

tell application "Adobe InDesign CS5"
set myoriginal to document 1
tell data merge properties of myoriginal
set myDataMergeProperties to properties
set dmRcount to record range of data merge preferences
set dmRcount to word -1 of dmRcount as real
end tell
end tell

This works great, and I have the script working to do exactly what I want, EXCEPT....
If using the same indesign file and I select a new data source, the record range of data merge preferences does not change  and I end up with the wrong record count.

I have no clue how to get around this so any suggestions would be greatly appreciated.

Paul



Paul, I've never used the data merge properties before, however, I know there's been other preferences in the paste, (say the export pdf prefs) that had to be 'set' twice before they'd work. If you changed them on an opened document and tried to export, it would not update until the next export, my workaround was just to set them twice, it seemed to work.. 

So my first suggestion would be try getting your dmRcount twice from the prefs. and see if that works. 

Another suggestion would be to close and re-open the document between each merge, does that help? 




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Indesign data merge
      • From: Wayne Melrose <email@hidden>
References: 
 >Indesign data merge (From: Paul Abney <email@hidden>)
 >Re: Indesign data merge (From: Wayne Melrose <email@hidden>)

  • Prev by Date: Re: ScriptEditorFormatting
  • Next by Date: number with one decimal
  • Previous by thread: Re: Indesign data merge
  • Next by thread: Re: Indesign data merge
  • Index(es):
    • Date
    • Thread