InDesign CS6 will not track text

I have written a script for InDesign CS6 to do some repetitive tasks. But when I try to set the tracking in a particular text box, AppleScript gives me an error. I have searched throughout this forum and on the internet in general but I cannot get this to work. See my snippet of code below. I’ve tried “tell contents of text frame”, “tell text of text frame textBoxCount” and “tell it” – none of them work. What on earth am I doing wrong!!! I had just ordered some reference books but they haven’t arrived yet

repeat until textBoxCount is 0
if text frame textBoxCount contains “To open: Fold and Tear along perforation” then
–set myTextBoxes to textBoxIDs + textBoxCount
tell text frame textBoxCount
if rotation angle of it is 90 then
set boxBounds to {“28p0”, “1p3”, “56p0”, “2p9”} --geometric bounds of it --[y1, x1, y2, x2]
set geometric bounds of it to boxBounds
set myStory to story 1 of text frame textBoxCount
tell myStory --text frame textBoxCount --text in – contents of
set tracking to 0
– set myContents to contents of it as string
–display dialog "Text in box " & textBoxCount & ": " & myContents
– set tracking of myContents to 0 – in text frame textBoxCount of text
end tell
–display dialog "Bounds of this text box: " & boxBounds
else
if rotation angle of it is -90 then
set boxBounds to {“28p0”, “48p9”, “56p0”, “50p3”} --geometric bounds of it --[y1, x1, y2, x2]
set geometric bounds of it to boxBounds
set myStory to story 1 of text frame textBoxCount
tell myStory --text frame textBoxCount --text in – contents of
set tracking to 0
end tell
–tell it --tell text in text frame textBoxCount contents of
– set myContents to contents of it as string
–display dialog "Text in box " & textBoxCount & ": " & myContents
– set tracking of myContents to 0 – in text frame textBoxCount of text
–end tell
– set tracking of text to 0 – in text frame textBoxCount
–else
– set boxBounds to geometric bounds of it
– display dialog "Bounds of text box " & textBoxCount & ": " & boxBounds --geometric bounds of it
end if
end if
end tell
end if
set textBoxCount to textBoxCount - 1
end repeat

Hi. Welcome to the forum. All variables must be defined, but, until your loop is almost complete, Textboxcount is not. This line is also problematic:

You must remove “of text frame textboxcount,” because that target is already in your tell block, and double references “collide.”

This is more standard and less verbose:

tell application "Adobe InDesign CS3"'s document 1
	repeat with aFrame in text frames
		tell aFrame's item 1
			if contents contains "To open:    Fold and Tear along perforation" and its rotation angle is in {90, -90} then
				set geometric bounds to {"28p0", "1p3", "56p0", "2p9"}
				set parent story's tracking to 0
			end if
		end tell
	end repeat
end tell

Thank you soooo much. I will definitely try that. I’ll let you know how it works.

I tried it and it worked!! Thank you so much for your help!!