Rework script from Indesign 2 to CS

I’ve tried a few things but can’t get this script to work in Indesign CS. If anyone can help me with a simple fix I’d be eternally grateful.

tell application “InDesign CS”
tell document 1
set theSelection to selection
repeat with anItem in theSelection
set theTarget to anItem
set theClass to class of theTarget
if page item 1 of theTarget exists then
tell theTarget
«event K2 fitc» given «class givn»:content to frame
set horScale to (horizontal scale of page item 1) + 0.5
set vertScale to (vertical scale of page item 1) + 0.5
if horScale is greater than vertScale then
set vertical scale of page item 1 to horScale
set horizontal scale of page item 1 to horScale
else
set horizontal scale of page item 1 to vertScale
set vertical scale of page item 1 to vertScale
end if
«event K2 fitc» given «class givn»:center content
end tell
end if
end repeat
end tell
end tell

Try this:

tell application “InDesign CS”
tell document 1
set theSelection to selection
repeat with anItem in theSelection
set theTarget to anItem
set theClass to class of theTarget
if graphic 1 of theTarget exists then
tell theTarget
fit given content to frame
set horScale to (horizontal scale of graphic 1) + 0.5
set vertScale to (vertical scale of graphic 1) + 0.5
if horScale is greater than vertScale then
set vertical scale of graphic 1 to horScale
set horizontal scale of graphic 1 to horScale
else
set horizontal scale of graphic 1 to vertScale
set vertical scale of graphic 1 to vertScale
end if
fit given center content
end tell
end if
end repeat
end tell
end tell

Kari

Thanks Kari, I’m eternally grateful!

James