Group every item - InDesign CS2

Hi
Can someone please tell me how I select and group every item in the active document in InDesign CS2 (pictures/text etc) like when you go

  • Edit → Select All
  • Object → Group
    I’ve had a look through MacScripter but haven’t found any examples I can get working and I don’t want to do it with UI scripting
    thanks!!

The syntax is likely odder than you think. I haven’t tried InDesign, but it took me days to figure out that this is how Illustrator does it:


tell application "Illustrator CS"
	activate
	
	--group all objects in file
	set all_page_items to every page item of current document --get a list of all page objects
	set group_ref to make new group item in current document --create an empty group "container"
	move all_page_items to end of group_ref --move all the items into the group
end tell

Perhaps InDesign uses a similar syntax?

Thanks for that - I think the syntax between them is very similar. If I change your script to this (it wouldn’t compile with ‘current document’)

tell application "Adobe InDesign CS2"
	activate
	
	--group all objects in file
	set all_page_items to every page item of active document --get a list of all page objects
	set group_ref to make new group item in active document --create an empty group "container"
	move all_page_items to end of group_ref --move all the items into the group
end tell

I get the following error:

Adobe InDesign CS2 got an error: Can’t make class group item.

If anyone has any ideas on this I’d be very grateful!!

Check the dictionary, there is probably a slight change to the syntax. I ran into that with paretn text box of a selection that changed to plural, allowing for a selection that goes across multiple text boxes. I don’t have ID2 here to check or test but think it might be something as simple as this.

Thanks for your help, but I’ve given up and decided to use UI scripting - this is the code if anyone wants it:

tell application "System Events"
	tell application process "Adobe InDesign CS2"
		click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
		click menu item "Group" of menu 1 of menu bar item "Object" of menu bar 1
	end tell
end tell

After a little poking around on the web, through ID2’s dictionary and the scripting guide I found that this is the proper syntax for making a group in CS2:

tell application "Adobe InDesign CS2"
	set TheSelection to selection
	tell document 1
		make group at page 1 with data {group items: TheSelection}
	end tell
end tell

Thanks for trying jerome - I still get this error though

Adobe InDesign CS2 got an error: Can’t make class group.

hmmm…You using CS2 right? I tested that before posting and it was working on my computer, and it’s working in CS as well here at home. You want to make sure that the you have a list of object references for the group items parameter. Technically I dont think you have to have them selected, you could build the list with a line like this:

make group at page 1 with data {group items:(every page item of page 1)}

You probably need to adjust the page number to reflect the page that you are working on or try spread if your group is straddeling pages in a spread.

try this:

tell application "Adobe InDesign CS2"
	tell document 1
		set thespread to active spread of layout window 1
		make group at thespread with data {group items:every page item of thespread}
	end tell
end tell

Which should make a group of every page item on the active spread of the document.