Hi folks, need a little help.
can I insert text into the frontmost document through Applescript ? Say the contents of a variable ? Having problems figuring out basic things.
thanks
simple applescripting
That should be possible. I'm very new to AppleScript, but I know you can use "set" to change a specified word or paragraph. For instance, I wanted to have a macro to create a fresh letter and insert the date. I created the letter template, writing "<DATE>" in the last paragraph. Here's AppleScript to create a new letter.
<pre>tell application "Nisus Writer Express"
activate
set letterTemplate to "INSERT_YOUR_PATH_HERE:Letter.dot"
open letterTemplate
if paragraph -1 of text of document 1 is "<DATE>" then
set monthNow to month of (current date) as string
set dayNow to day of (current date)
set yearNow to year of (current date)
set dateNow to monthNow & " " & dayNow & ", " & yearNow
set paragraph -1 of text of document 1 to dateNow
end if
end tell</pre>
This is my very first -- and so far only -- AppleScript, so I imagine it's far from perfect, but it seems to work.
--Craig
<pre>tell application "Nisus Writer Express"
activate
set letterTemplate to "INSERT_YOUR_PATH_HERE:Letter.dot"
open letterTemplate
if paragraph -1 of text of document 1 is "<DATE>" then
set monthNow to month of (current date) as string
set dayNow to day of (current date)
set yearNow to year of (current date)
set dateNow to monthNow & " " & dayNow & ", " & yearNow
set paragraph -1 of text of document 1 to dateNow
end if
end tell</pre>
This is my very first -- and so far only -- AppleScript, so I imagine it's far from perfect, but it seems to work.
--Craig