How change PowerPoint zoom level with AppleScript? - applescript

I'm using AppleScript to show PowerPoint slides as part of a manual testing/inspection step for code that generates the slides.
It's all working nicely, but I can't work out how to tell PowerPoint to zoom to 'fit' or 188% in my case.
set the zoom of the active window to 185 does nothing.
How do I get a reference to the property of interest here?

This works on Microsoft Office 2016, tested on Version 15.27:
-- Example: Set zoom to 188% --
tell application "Microsoft PowerPoint"
tell active window to set zoom of its view to 188
end tell
-- Example: Set zoom to fit --
tell application "Microsoft PowerPoint"
tell active window to set zoom to fit of its view to true
end tell

Related

Need an Applescript to go to a specific slide number in PowerPoint

I need a simple AppleScript that will cause PowerPoint to move to a specified slide number. I unfortunately am not familiar enough with AppleScript to properly interpret the information in the Applescript Library for PowerPoint. I think if someone can get me started I can take it from there.
The script just needs to reference the active presentation. If I could speak to my computer I just need to tell it to "go to slide #5" or "go to slide #2", etc.
The script needs to work while in Slideshow mode as the presentation will be running on a separate screen. Thanks so much for the help, I haven't been able to find this anywhere.
my gotoSlide(2)
on gotoSlide(whichSlide)
-- whichSlide is the integer position of the slide
tell application "Microsoft PowerPoint"
activate
tell active presentation
set theView to view of document window 1
go to slide theView number whichSlide
end tell
end tell
end gotoSlide

Using AppleScript to set borders in Numbers?

I've successfully managed to get AppleScript to manipulate the background colors in my Numbers document by refering to the background color property. However, I would like to set the borders of a selection or range of cells as well.
I've looked in the Dictionary in AppleScript Editor for a command or property that could help me out here, but I haven't found anything. Is it the case that it's not possible to create borders in Numbers with AppleScript?
There is nothing in the AppleScript dictionary to allow this functionality (which is awful, IMO, but perhaps Apple will add this in the future if enough people complain).
You can use SystemEvents to interact with the interface of Numbers to add the borders:
-- Set the selection range
tell application "Numbers"
make new document
tell front document to tell active sheet to tell table 1
set selection range to range "A3:C6"
end tell
end tell
-- Asks System Events to interact with the interface
tell application "System Events" to tell application process "Numbers"
-- Asks the main window to click on the button called 'Cell' (the name depends of your system language)
tell window 1
click radio button "Cell" of radio group 1
-- Scroll area 4 is the inspector area
tell scroll area 4
-- The first incrementor of the inspector is the borders' one.
increment incrementor 1
end tell
end tell
end tell
If you want to manipulate other elements of the interface, I recommend using the Accessibility Inspector app that comes with Xcode.

Resize Powerpoint Slideshow Window with Applescript

I'm trying to resize the slideshow window using Applescript and Powerpoint 2011 for Mac.
In the past I've used VBA to do the job, but here it seems impossible to do with Applescript.
The script is:
tell application "Microsoft PowerPoint"
set show type of slide show settings of active presentation to slide show type speaker
set theSSW to run slide show slide show settings of active presentation
set height of theSSW to 300
set width of theSSW to 400
end tell
(the script above is directly copied from Applescript Reference)
The problem is that the slideshow window is cropped but not resized.
That is making me crazy.
Any idea?
EDIT: Definitely there are 2 ways to launch and open a PPT file on Mac with Applescript:
In "speaker mode" the window shrinks but only a portion of the presentation is shown. the presentation is not resized but I can advance on mouse click.
In "window mode" the presentation is resized. I can view all the slide but I cannot advance on mouse click. (If I set the "window mode" manually, the mouse click works even if I THEN resize it with Applescript)
If I work on Windows this problem doesn't exist.
Flying completely blind here, but what do you get if you do:
tell application "Microsoft PowerPoint"
set ssw to slide show window of it
properties of ssw
end tell
or
tell application "Microsoft PowerPoint"
set ssw to slide show window 1
properties of ssw
end tell
What I'm looking for are the window properties that hopefully can be changed. I'm hoping to get either height and width or (as is more commonly the case) the bounds of the slide show window. I'm just not clear on the syntax for PowerPoint (don't have it).
[edit] well, I see from the pdf docs that bounds is read-only. Hm. I'd have to get my hands on the sw to test.
This (in VBA) will give you a window that displays the entire slide:
With ActivePresentation
With .SlideShowSettings
.showType = ppShowTypeWindow
.ShowScrollbar = msoFalse ' might or might not need this
.Run
End with
With .SlideShowWindow
.Height = 300
.Width = 400
End With
End with
Your presentation will need some means of advancing itself (as you've noticed).
You'd want to manually or programmatically add an advance button to each slide.
Translation to Applescript is left to the discretion of the reader.

Applescript detect what slide is showing in Keynote

As the title says-
Is there a way to detect what slide is showing in a keynote presentation (using applescript)?
And yes, I am aware of how to change slides with applescript, I just need to detect what slide is already active.
SOLVED! >>> SEE BELOW
(Don't have enough reputation to answer my own question, so I'll just stick it here.)
I found a way round it thanks to this guy's script: http://code.google.com/p/keynotetweet/
For each slide in Keynote you get the option to attach invisible notes (not the yellow stickies, its a text box at the bottom of the page. Change the view to "Show Presenter Notes"). Here you can store a trigger string, ie "action". So create a keynote and put "action" in the notes of one slide. Start up the applescript then the slideshow, and when the slide with "action" in the notes is visible, the applescript will pick up it up and do whatever you set it to do.
repeat
tell application "Keynote"
set slideNotes to get notes of current slide of first slideshow
if text of slideNotes is equal to "action" then
say "Is this the slide you're looking for?"
end if
end tell
end repeat
Enjoy!
tell application "Keynote"
tell slideshow 1
get current slide
end tell
end tell
gives you
slide 3 of document "Untitled" of application "Keynote"

Using Applescript run powerpoint slide show of specified slide in the presentation

I want to run PowerPoint slide show for only a particular slide.
After my research, I tried following but I did not get expected result.
Both of the scripts, starts slide show but from the first slide.
1)
`tell application "Microsoft PowerPoint"
activate
open "/Users/sanjeev/pppp.ppt"
set slideShowSettings to slide show settings of active presentation
set starting slide of slideShowSettings to 4
set ending slide of slideShowSettings to 4
run slide show slideShowSettings
end tell`
2)
`tell application "Microsoft PowerPoint"
activate
open "/Users/sanjeev/pppp.ppt"
set slideShowSettings to slide show settings of active presentation
run slide show slideShowSettings
go to slide slide show view of slide show window 1 number 4
end tell`
The second script gives an error also:
error "Microsoft PowerPoint got an error: slide show view of slide show window 1 doesn’t understand the go to slide message." number -1708 from slide show view of slide show window 1
I saw a question Want Applescript to change a Keynote presentation to a particular slide
But I think that works only for KeyNote.
Can anyone help?
Thanks
This seems to work. It looks buggy to me. When the script is run the screen goes black, then flashes the slide then goes black then finally displays the slide. I don't know if this is due to the script or the implementation of Applescript/ppt from Microsoft. I say the latter.
tell application "Microsoft PowerPoint"
set temp to active presentation's slide show settings
set temp's starting slide to 2
set temp's ending slide to 2
set temp's range type to slide show range
set temp's advance mode to slide show advance manual advance
run slide show temp
end tell

Resources