Hi,
I just need to replace some text that is selected with the date. How do you replace the selection?
tia,
aaron
Hi,
I just need to replace some text that is selected with the date. How do you replace the selection?
tia,
aaron
spudmonkey,
Donāt know if this is exactly what youāre looking for or not, but for what itās worth, here 'tis.
tell application "InDesign CS"
activate
set selection to text frame 1 of active document
set contents of text frame 1 of active document to "other text"
end tell
I just made a document and put some text in it and then changed it via the script. This works for CS1. Donāt know about CS2. I know this is pretty basic, but may be a start. (You donāt have to use the set selection statement above. I just did that for my testing purposes.)
PreTech
That replaces all the text in the frame. I just need to update the date string. Iād like to select some text, run the script and have it replace the selected text. Hmmmm.
Would a paste command be the way to do it?
Getting thereā¦
set mydate to (current date) as text
tell application "InDesign CS"
activate
cut selection of text frame 1 of active document
set insertion point 10 of text frame 1 of active document to mydate
end tell
The above cuts the selection and then inserts the date into the text frame, but how
do I get the cursorās current position, as thatās where I want the date inserted into.
tia,
aa
Here ya go Spud:
set mydate to (current date) as text
tell application "InDesign CS"
if exists document 1 then
tell document 1
set contents of item 1 of selection to mydate
end tell
end if
end tell
Note that the selection is going to be a list even if there is just one item selected
ah⦠which explains why āset contents of selection to mydateā didnāt work. Scripting is hard. Man, you are just too freaking smart. Thank you once again.