InDesign - Replace text selection?

Hi,
I just need to replace some text that is selected with the date. How do you replace the selection?

tia,
:confused: 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,
:confused: 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.