itemByRange can take some getting used to. The way you used it, it
returns a Character-Array object (it's kind of hard to explain).
You can change that into a normal array of Characters with
A better way to get a text range is:
mySelection = app.selection;
You know about these, right?:
Keys for finding and changing text
Insert selected text into Find What box
Insert selected text into Find What box and finds next
Find next occurrence of Find What text
Shift+F2 or Alt+Ctrl+F
Shift+F2 or Option+Command+F
Insert selected text into Change To box
Replace selection with Change To text
Thanks for your info about using texts.itemByRange. Just tested it, and the item returned was of type "Text", which is just what I wanted.
It seems odd to me that a texts.itemByRange() would accept a character and not an index integer as arguments. It also seems odd that it returns a single Text object, and not an array of Texts. But it works -- which is the main thing!
Thanks for your post. I know about those keyboard shortcuts, but they won't be much use for me. When I'm taking in corrections I'll tie the script to a keyboard shortcut and use it to quickly jump to a string of characters some lines further down. This is to save using the mouse too much (RSI!) and for general speediness. May not save much time, but it all mounts up -- my job can be quite repetitive!
I could do a control-F and type in a string into the InDesign find dialogue box then tap enter, but there will often be, say, a paragraph style in the "find format" box already, or the last find I did may have been case sensitive, and so it can take a few mouse clicks to reset the find dialogue box.