Thank you, Niel, for the exact answer that I needed at the exact time! Thanks also to the users who asked the question. One point: After i got my word count using your instructions, I decided to see what a right-click in the open Script application would tell me and I found one crucial difference: In the first menu after right-clicking, I hit "tell blocks," then clicked again and got "tell application." The wording that pops up matches yours, except for that numeral 1, and without the 1, the script does not work for me. Just wondering: Does the character have to be a 1, or would other characters work too?
except for that numeral 1, and without the 1, the script does not work for me. Just wondering: Does the character have to be a 1, or would other characters work too?
The numeral "1" is a way of identifying which document window TextEdit should count the words in. Try this: create a second document in TextEdit with a different number of words in it. Now go back to the script editor and change the "1" back and forth to a "2". You'll get different answers, depending on which window is the frontmost in the TextEdit. They're identified with "1" as the frontmost, "2" as the second, and so on if there are more windows.