indd, Selection Width and Height

I am trying to have a script capture the value for the height and width one or multiple items selected within an InDesign CS document?

With that, I could then have the script copy the selected objects and then open a new document in which it passes those values into the height and width. The selection would then be pasted into this new document that has page bounds cropped right up to the selection bounds”I hope?

The selection part is what I really don’t know how to do? - Any advice?

From an initial look InDesign does not have a bounds of the selection as a single measurement so you would have to parse through the items in the selection. As I recall there is an Illustrator thread on this exact subject, and you might want to read through that for other solutions. This should work:

set DocBounds to {0, 0, 0, 0}
tell application "InDesign CS"
	set SelectionBounds to visible bounds of selection
	repeat with i from 1 to count of SelectionBounds
		if DocBounds is {0, 0, 0, 0} then
			set DocBounds to item i of SelectionBounds
		else
			if item 1 of item i of SelectionBounds < item 1 of DocBounds then set item 1 of DocBounds to item 1 of item i of SelectionBounds
			if item 2 of item i of SelectionBounds < item 2 of DocBounds then set item 2 of DocBounds to item 2 of item i of SelectionBounds
			if item 3 of item i of SelectionBounds > item 3 of DocBounds then set item 3 of DocBounds to item 3 of item i of SelectionBounds
			if item 4 of item i of SelectionBounds > item 4 of DocBounds then set item 4 of DocBounds to item 4 of item i of SelectionBounds
		end if
	end repeat
	set DocHeight to ((item 3 of DocBounds) - (item 1 of DocBounds))
	set DocWidth to ((item 4 of DocBounds) - (item 2 of DocBounds))
end tell
return {DocHeight, DocWidth}

Jerome,
I can’t thank you enough! This is working, and it will surely help in more instances than just this one instance I am shooting for at the present moment.

-jeff