• 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: Wayne Melrose <email@hidden>
  • Date: Tue, 19 Jul 2011 07:19:49 +0200


On 18. juli 2011, at 21.22, Paul Abney wrote:

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


Hi Paul, 

I had a bit of trouble getting my head around the halving and adding to the other variable in here.. But I see what you're attempting is to try and quickly find the number. I'm thinking that part of the problem might be related to the repeat actually stopping when the stepby is 1, perhaps you should repeat until blnNumberFound and then use an if statement to set that variable? 
if StebBy =1 then 
set blnNumberFound to true
end if 

You also mentioned that your eventual goal is to use CSV files? Have you got a sample file of this data source? I still think it's worth checking out other means to get the count. 

Also, how necessary is it to have this count number? I understand your goal is to loop through each data merge page and save it as a separate file? Could you not just do this until it errors and stop. If you still need the total number, you could count each time you save, or simply count the number of files at the end. 

Just trying to spart some thoughts :D 

I'd be happy to take a look at the data source with you and see if there's other options. 

Wayne 






 _______________________________________________
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

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

  • Prev by Date: Re: number with one decimal
  • Next by Date: Re: number with one decimal
  • Previous by thread: Re: Indesign data merge
  • Next by thread: apple mail trigger an as
  • Index(es):
    • Date
    • Thread