your code works just fine for me, just doc.changeText(); changed to app.changeText();
no 'escapes’ for ampersand needed.
What is the difference between doc. and app., as I am only changing the text on the doc I have specified, would I not want to do the change at a document level?
I created some new scripts with the & in different positions in the string, and it appears to works fine, except on the one script that initially gave me the problem...strange...
Than you should define doc first, like this:
var doc = app.activeDocument;
Now your code might throw an error 'doc is not defined'
Oh, it is defined, I just didn't include it in the snippet I gave. Sorry about that. I changed around the page layout on the document after posting this question, and the 'glitch' doesn't seem to be happening anymore. I don't what I did, but the script is now working without changing the script.
What is the difference between doc. and app., as I am only changing the text on the doc I have specified, would I not want to do the change at a document level?…
app.changeText() will change text for all open documents.
doc.changeText() will change text for the open document specified with variable doc.
You could even narrow the scope of your change action to let's say a story in your document. Or a range of text.
Scripting changeText() is more flexible than in the UI. E.g. there is no selected text needed to use changeText() on text.