New poster, new topic, but: I’m racking my brains trying to figure out how AppleScript controls the shapes selected in PowerPoint. (What I’d like to do is automatically select all objects of a certain color so that I can subsequently manipulate them manually, but that’s – perhaps – not possible.)
The documentation lets us unselect whatever shapes are selected, and we do this by talking directly to the selection:
tell application "Microsoft PowerPoint"
set theSelection to selection of document window 1 of active presentation
tell theSelection
unselect
end tell
end tell
There is, however, no documentation allowing us to ‘select’ anything, but we can do it anyways, and this is where it gets very confusing. The slide lets us select an arbitrary item (in this case ‘item 1’, but ‘item 2’ or ‘item 505’ work, if you have that many shapes on the slide):
tell application "Microsoft PowerPoint"
set theSelection to selection of document window 1 of active presentation
set theSlide to slide 1 of slide range of theSelection
set theShapes to shapes of theSlide
tell theSlide
select item 1 of theShapes
end tell
end tell
In the Log, it looks as if ‘theShapes’ is a list. Indeed, we can select all items very easily if we just ask the slide to select that list:
tell application "Microsoft PowerPoint"
set theSelection to selection of document window 1 of active presentation
set theSlide to slide 1 of slide range of theSelection
set theShapes to shapes of theSlide
tell theSlide
select theShapes
end tell
end tell
Makes sense; theShapes is now all the shapes on the slide, and we’re asking the slide to select theShapes, which selects all of them. However, if we create our own list with just one shape in it, it still selects everything on the slide:
tell application "Microsoft PowerPoint"
set theSelection to selection of document window 1 of active presentation
set theSlide to slide 1 of slide range of theSelection
set theShapes to shapes of theSlide
set shapeList to {}
set end of shapeList to item 1 of theShapes
tell theSlide
select shapeList
end tell
end tell
(We can get around this by saying ‘select item 1 of shapeList’, incidentally; then we are just feeding the ‘select’ command a single shape object.)
Has anyone successfully used the undocumented ‘select’ command to select more than one, but fewer than all, shapes on a slide?
Any thoughts very welcome!
P.