If you need to insert similar text into documents often, you may want to create a JavaScript (JXA) task in Automator that makes it easier. In this example, we'll look at inserting a piece of text that contains two variables, such as: (Refer to page X or report Y). The script will prompt you for the page and report, and then insert the test into the document you are working on.
▶ You can also watch this video at YouTube.
▶
▶ Watch more videos about related subjects: Automator (50 videos).
▶
▶ Watch more videos about related subjects: Automator (50 videos).
Here is the text of the JXA script:




var pageNumber = app.displayDialog('Page Number?', {defaultAnswer:''});
when I compile your script I get this error:
Error on line 8: SyntaxError: Invalid character '\u8216'
The first line of this message is line 8
Do you know what error is?
Jeff: Make sure you don't have an extra invisible character somewhere. Not just on that line, but the next one (which is line 8 if you copied and pasted).
What is the application you mentioned in your video?
Jean-Claude: Not sure what you mean. I am using Automator in the video. I am demonstrating the script by inserting text into Pages. If you mean something else, let me know the time in the video where I mention it and I will try to clarify.
At approx 34 seconds in the video, you say "there are some apps you can purchase..."
Jean-Claude: Apps like TypeIt4Me and TextExpander.
OK, thanks!
That is the coolest thing I have ever seen. I have been using Mac for six years and am stil learning things it can do.
@Jean-Claude:
There is another app for text automations: Typinator.
I use it since textexpander went on to monthly subscriptions.
Works great.