I think you must specify what kind of window it is, for the id property to work!
tell application "Microsoft PowerPoint"
set a to its presenter view window
set a to its slide show window
set a to its document window
set a to its basic window
end tell
And maybe it doesn’t work to just set the index of that window to 1, but we’ll take it form there.
I can find the window if I use “get every document window” and iterate through them, but they don’t seem to have an ID property, so I will have to use the name, which isn’t guaranteed to be unique, so not as good as using he ID.
However, even when I have the window, I still haven’t been able to figure out how to get it to come to the front in PowerPoint. Setting the index produces an error, setting it’s visible or zoomed property to true seems to have no effect, etc. Any idea what I can do with the window to get it to come to the front?
I think the name of the window should suffice, reading through the dictionary of powerpoint, I see that the id is missing as a property and the index is named entry_index.
Drop powerpoint onto the library window of AppleScript editor to get access to it, if you don’t have it, there you can read through what properties, and commands PowerPoint provides.
This little snippet puts the previous last PowerPoint window (of two) to the foreground.
local a, b, c
tell application "Microsoft PowerPoint"
set a to its last document window
set b to entry_index of a
set c to id of its document window b
--> missing value
select its document window b
end tell
The whole point was really to show how to access a window by entry_index, which you maybe must type as entry index.
I think you should be able to use the name of document window to access a window as well.
Other reference forms like last window, or middle for that matter, would also work of course, but doesn’t serve as a meaningful identificator of a window.
If you just want to bring the active PowerPoint window to front, in front of the previous active app, then this line would suffice:
do shell script " open -b \"com.microsoft.Powerpoint\""
Thanks, that was the clue for me to get this figured out!
Using “select” on the document window was the way to get it to bring the window forward.
For anyone else searching for similar solutions, it turned out that I also had to do this for Microsoft Word and Excel which also don’t honor the “set index” command. For them, you need to use “activate object” on the “window” of the given name (as opposed to “document window” in PowerPoint).
Here’s a little more info in case anyone finds this via a google search. If the window was minimized, then it doesn’t automatically un-minimize when select (PowerPoint) or activate object (Word and Excel) is called on the window. But if you do “set collapsed of w to false” (if w is your window object) before activating the window, it will un-minimize.