InDesign - "Move" Text Into Anchored Text Frames

Hi everybody,

I have a long InDesign document (about 200 pages) with text flowing in a main text frame. Now some of the paragraphs have to be put inside anchored text frames that flow with the main text. I wrote a script that stores the paragraphs of a given selection in a variable, deletes the selection, creates the anchored frames and puts one paragraph in every single text frame. My script works so far, but the disadvantage is that the paragraph and character styles of the selected text are not retained. This is what I have so far:


tell application "Adobe InDesign CS3"
	activate
	if (count documents) > 0 then
		tell active document
			if selection is {} then
				beep
			else
				if class of selection is text or class of selection is text style range then
					set mySelection to (every paragraph of selection)
					delete selection
					repeat with i from 1 to (count of items in mySelection)
						set myParagraph to (characters 1 thru -2 of item i of mySelection) as text
						tell (first insertion point of selection)
							make new text frame with properties {geometric bounds:{0, 0, 2, 15.05}, contents:myParagraph}
						end tell
						set contents of (first insertion point of selection) to return
					end repeat
				else
					beep
				end if
			end if
		end tell
	end if
end tell

Does anybody know how I can retain the styles when “moving” the text into the text frames?

TIA

Frank

try using copy paste instead of set contents.