The script works OK here. Try opening it in AppleScript Editor (choose Edit Script from the Scripts panel flyout menu) and run it from there -- then report which lie of the script the error is happening on.
For some reason the faulty behavior has disappeared today. Yesterday, I restarted the computer at least once, but continued to get the same error; in AppleScript Editor the word "range" in the second line of the script proper (not counting the initial comments) was highlighted. The one major change in my system was upgrading Mac OS X to 10.6.6 overnight.
Today the script works, but it turns out it isn't doing what I need: I hadn't quite understood from the descriptive comments that it separates every frame into a separate story (as well as wiping out all overset text, which I did get). What I need is to be able to split a story into two (no more) at a precise point in the text. If I have to make that point coincide with a break between two frames, I can live with that (though it would be a heck of a lot easier if I could simply position the text cursor at the point where I want to make the break). An even better solution, which I expect is unrealistic, would be to split the story at every occurrence of a particular paragraph style. (The sections I need to split up are of variable length, often covering multiple frames.)
I have no expertise in scripting. Can you suggest a way to achieve what I'm after? Has anyone already produced a suitable script?
You can't split a story mid-frame -- by definition, a frame can only contain one story. What a script could do is break the link between two text frames, and split the story between the two resulting text flows.
Please be patient. I said I could live with that, but also that I have no expertise in scripting. So: I know that I need to manually ensure that the point where I want to split is at the end of a frame. Please advise me how to
break the link between two text frames, and split the story between the two resulting text flows
because I don't know how to achieve this, either by hand or by scripting.
1 person found this helpful
OK, suppose you have the cursor somewhere in some text in a frame. When you run the following script, all text beyond the selected insertion point will moved to the following frame, and the link between the two frames will be broken:
tell application "Adobe InDesign CS5"
set theSel to item 1 of selection
set theOffset to index of theSel
set theStory to parent story of theSel
set theFrame to item 1 of (parent text frames of theSel)
set nextFrame to next text frame of theFrame
set next text frame of theFrame to nothing
set parent story of nextFrame to ""
move (text from character theOffset to character -1 of theStory) to after parent story of nextFrame
Many thanks, Shane. However, the script as given breaks down at line 8 with the result "error "Adobe InDesign CS5 got an error: 'parent story' is a read only property." number 30474". What actually occurs is that the link between the current frame and the next is broken, but the text has not been moved -- it is now overset from the current frame. A little experimentation has shown that that line needs to be:
set contents of parent story of nextFrame to ""
and the script now works as advertised. For any future readers of this thread, I offer a screen shot:
Message was edited by: Jeffrey Dean