I need to find a specific text string in the current active document & if it doesn’t exist then display an alert. The script below works in some documents but not all of them. Sometimes I get this error when I have more than one document open or when the file contains more than 1 page:
Can’t make {text from character 2 to character 11 of story id 274567 of document id 63 of application “Adobe InDesign CS6”, text from character 2 to character 11 of story id 274648 of document id 63 of application “Adobe InDesign CS6”} into type Unicode text.
What possible can be wrong?
set findThis to "XX28.18"
tell application "Adobe InDesign CS6"
activate
--clear fields ...
set find text preferences to nothing
-- set find options
set case sensitive of find change text options to true
set whole word of find change text options to true
set include hidden layers of find change text options to false
set include locked layers for find of find change text options to false
set include locked stories for find of find change text options to false
set find what of find text preferences to findThis -- load string into the 'Find'
tell document 1
set pageCode to find text findThis
if pageCode is not in findThis then
display alert "XX28.18 not found"
end if
end tell
set find text preferences to nothing
end tell
Model: iMac (Retina 5K, 27-inch, Late 2015)
AppleScript: 2.8.1 (183.1)
Browser: Safari 537.36
Operating System: Mac OS X (10.11.6)