InDesign Formating First Paragraph in a Text Box

Hi all
Total newby here…

I am trying to go through all my textboxes of the same structure and format the first paragraph with one style the second with an other and so on.

As soon as it comes to talking to a paragraph I get error messages.

Can somebody give me some hints?

Thanks heaps


tell application "Adobe InDesign CS3"
	tell active document
		
		--Create a paragraph style named "myParagraphStyle" if
		--no style by that name already exists.
		try
			set myParagraphStyle1 to paragraph style "myParagraphStyle1"
		on error
			--The paragraph style did not exist, so create it.
			set myParagraphStyle1 to make paragraph style with properties {name:"myParagraphStyle1"}
		end try
		try
			set myParagraphStyle2 to paragraph style "myParagraphStyle2"
		on error
			--The paragraph style did not exist, so create it.
			set myParagraphStyle2 to make paragraph style with properties {name:"myParagraphStyle2"}
		end try
		
		
		
		try
			set myColor to color "Red"
		on error
			--The color did not exist, so create it.
			set myColor to make color with properties {name:"Red", model:process, color value:{0, 100, 100, 0}}
		end try
		
		
		try
			set myCharacterStyle to character style "myCharacterStyle"
		on error
			--The style did not exist, so create it.
			set myCharacterStyle to make character style with properties {name:"myCharacterStyle"}
		end try
		
		
		
		set myPageItems to text frames
		
		
		tell myPageItems
			if (count myPageItems) > 0 then
				repeat with myCounter from 1 to (count myPageItems)
					set myPageItem to item myCounter of myPageItems
					
					--THIS PART WORKS
					
					set applied paragraph style of paragraphs of text frame myPageItem to paragraph style myParagraphStyle1
					
					
					set inset spacing of text frame preferences of myPageItem to {7, 0, 0, 0}
					
					
					
					--THIS PART DOES NOT WORK
					--set point size of paragraph 1 of myPageItem to 20
					
					
					
					
					
					
					
					--SOME EXTRAS COMMENTED OUT
					--apply paragraph style using myParagraphStyle1
					
					--set myParagraphs to paragraphs of myPageItem
					--set paragraph style of paragraph 1 of myPageItem to myParagraphStyle1
					
					--set point size of paragraph 1 of myPageItem to 20
					
					
					
					
					
				end repeat
			end if
		end tell
	end tell
end tell

Hello,

The object of your command, myPageitem, is a complete reference to a text frame, so you don’t need to add “text frame” to latter commands.


--THIS PART WORKS
		set applied paragraph style of paragraphs of myPageItem to myParagraphStyle1