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.