Two months ago I wrote a script which worked very well.
Now I had to change just the name of the character style and after saving, the script is not able to define the variable k anymore. The original script is still working and when i make a duplicate in the Finder, this works too. When I save a copy from the editor it also works. But as soon as I save it after making a single change in the script, even just the removal of an extra return at the end of the script, so the content was’nt really changed, the script doesn’t work anymore.
Applescript Runtime Error
Can’t get k of {text from character 11 to character 44 of story id 6372 of document “EMMmargewoordWeg.indd”, text from character 594…etc, etc,…}
In Script Debugger I can see that foundText is set to the list you see in the error, and lastitem is set to 45
but k remains undefined
I’m working on Max OS 10.6.5 intel with Indesign CS3 latest update
Indesign was not updated since the making of the first script
Below you find the original script
Anyone, any ideas?
tell application "Adobe InDesign CS3"
activate
set find text preferences to nothing
set change text preferences to nothing
set find what of find text preferences to ""
set properties of find text preferences to {applied character style:"Margewoord"}
set properties of change text preferences to {applied character style:"Margewoord-done"}
tell document 1
find text
set foundText to result
--display dialog foundText
set lastitem to (count of result)
repeat with k from lastitem to 1 by -1
set the selection to item k of foundText
set mySelection to the selection
--display dialog mySelection as text
set myParagraph to mySelection's items as text
--display dialog myParagraph as text
tell (first insertion point) of selection
make new text frame with properties {geometric bounds:{0, 0, 15, 25}, contents:myParagraph, applied object style:"MargeObjectstijl"}
end tell
-- set contents of (first insertion point of selection) to return
end repeat
change text
end tell
end tell