InDesign Text Frame Re-size Script?

I’m very green about InDesign’s script dictionary. This is so simple… but I can’t get my head around it.

I have an 80 page catalog, opened and active, lots of text and graphics frames in it. One type of text frame holds one part number per frame. This text frame has a particular object style called, you guessed it, ‘partNumber’. There might be 1 to 15 or so part number text frames per page.

The client has had to change all of his part numbers mid way through the project. I have to lengthen each text frame with the object style ‘partNumber’ to 25 mm, keeping the same height.

I’m looking for a simple script that takes each text frame styled ‘partNumber’, and set the horizontal length of the frame to 25 mm. So it goes along the lines of:

tell application “InDesign CS3”
tell active document
– set the horizontal length of (every text frame with the object style “partNumber”) to 25
end tell
end tell

I don’t know what loop to use. I’ve seen the word ‘every’ used in a couple of scripts and thought I could use that, but I’m stymied.

Hi,

try something like this


tell application "Adobe InDesign CS3"
	tell document 1
		repeat with oneFrame in (get text frames whose name of applied object style is "partNumber")
			set {a, b, c, d} to geometric bounds of oneFrame
			set geometric bounds of oneFrame to {a, b, c, 25}
		end repeat
	end tell
end tell

Woo, so CLOSE!

That’s magic, Stefan, thanks a million. The only change I had to make was your ‘25’ number.

FYI: In InDesign, the geometric bounds co-ords of a text frame are absolute points relative to the ruler origin - {top left, bottom left, top right, bottom right}. So horizontal length is just bottom left+whatever horizontal length I want.


tell application "Adobe InDesign CS3"
	tell document 1
		repeat with oneFrame in (get text frames whose name of applied object style is "partNumber")
			set {a, b, c, d} to geometric bounds of oneFrame
			set geometric bounds of oneFrame to {a, b, c, b+25}
		end repeat
	end tell
end tell

Again, thanks heaps Stefan!

-Oro

wow, this script is almost exactly what i was looking for, too! thanks everybody. :slight_smile: one question, though: is there any way to throw an if statement that will only alter text boxes that meet one dimensional requirement? i.e. “if a = 3 then set geometric bounds of oneFrame to {a + 2, b, c, d}” and then move to next page if conditions not met? sorry, i am new to applescript.

thanks!
micah

EDIT: i figured it out right after i posted this reply. :wink: in case anyone else cares:


tell application "Adobe InDesign CS3"
	tell document 1
		repeat with oneFrame in (get text frames)
			set {a, b, c, d} to geometric bounds of oneFrame
			if {a = 3} then set geometric bounds of oneFrame to {a + 2.0228, b, c, d}
		end repeat
	end tell
end tell