Indesign - assign text styles while adding text in text frames ??

Hi
I am new to scripting Indesign CC and am trying to learn the syntax.
How do I assign styles to text being added to and existing text frame.

Here is what I am doing so far to test this issue. It’s simple I know :slight_smile:

This works ok but now I need to style each new item as it is being added.

Thanks in advance for help with this.

property theLetter : "A. "
property prodName : “The Name of the Product”
property newOrNot : “NEW”
property thePrice : “$14.99”
property theCopy : “Green Stuff can always make you smarter and blah blah blah !” & return & “More interesting data about the product that you might want to know”
property TheLastBit : “Some other stuff HERE …”
property theTADA : “------< Ta Da !$! >-----”

repeat with x from 1 to 3
tell application “Adobe InDesign CC”
tell parent story of text frame x of page 1 of document 1

		set applied font to "Arial"
		set contents of insertion point -1 to theLetter & prodName & "   "
	end tell
end tell

tell application "Adobe InDesign CC"
	tell parent story of text frame x of page 1 of document 1
		set contents of insertion point -1 to newOrNot & "   "
	end tell
end tell

tell application "Adobe InDesign CC"
	tell parent story of text frame x of page 1 of document 1
		set contents of insertion point -1 to thePrice & return
	end tell
end tell

tell application "Adobe InDesign CC"
	tell parent story of text frame x of page 1 of document 1
		set contents of insertion point -1 to theCopy & return
	end tell
end tell
tell application "Adobe InDesign CC"
	tell parent story of text frame x of page 1 of document 1
		set contents of insertion point -1 to TheLastBit & return
	end tell
end tell

tell application "Adobe InDesign CC"
	tell parent story of text frame x of page 1 of document 1
		set contents of insertion point -1 to theTADA & return & return
	end tell
end tell

end repeat

Oakley

Model: iMac 10.9, IndesignCC, Script DeBugger5
AppleScript: 2.6.1
Browser: Safari 537.75.14
Operating System: Mac OS X (10.8)

Sorry I was not complete with my information.

Each added item needs it own style sheet assignment.

Thanks
Oakley

I promise I will learn to do these posts properly :slight_smile:

You can use the apply character style command, or set the applied character style property. You will need to know the range of text you want to apply to. Something like:

	tell document 1
		set applied character style of text from character 3 to character 5 of parent story of text frame 1 to character style "AA"
		-- or
		apply character style text from character 3 to character 5 of parent story of text frame 1 using character style "AA"
	end tell

Thank you Shane
I will give it a try
Oakley