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.
Related
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
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
The following script, when run in AppleScript Editor returns as text the autoshape type of the objects on the page. However, when run from the applescript menu from within PowerPoint, it returns a script constant instead.
I'm using a more complicated version of this to send properties of the objects to different applications based on what auto shape type it is... tables go one place, placeholders another, and rectangles et al to third. I'm also launching this from within PPT to push out the data, and can't really pull it from any of the other apps, so the AppleScript menu would be where I want it to be.
Can anyone tell me why the same script gives two results?
Thanks,
Alex
tell application "Microsoft PowerPoint"
set currentSlideNumber to slide index of slide range of selection of document window 1
set theSlide to slide currentSlideNumber of active presentation
end tell
getProperty(theSlide)
to getProperty(theSlide)
tell application "Microsoft PowerPoint"
repeat with thisShape in (get every shape of theSlide)
set shapeType to shape type of thisShape
set shapeContent to content of text range of text frame of thisShape
display alert (shapeType as string)
end repeat
end tell
end getProperty
Converting constants (or application properties which standard applescript doesn't understand) to text is tricky. My guess is that when in the powerpoint menu the script understands the constant better and thus you see that.
In any case, I had the same issue with Finder constants and decided to handle the conversion to text myself with an if statement. It's a cumbersome solution because you have to account for every constant but at least you know it will happen properly.
Here's an example. Suppose there is a shape constant of "rect" which stands for a rectangle, and "circ" standing for circle.
NOTE: you can probably use the name of the actual property instead of the constant in the code.
to getProperty(theSlide)
tell application "Microsoft PowerPoint"
repeat with thisShape in (get every shape of theSlide)
set shapeType to shape type of thisShape
if shapeType is <<rect>> then
set shapeTypeText to "rectangle"
else if shapeType is <<circ>> then
set shapeTypeText to "circle"
end if
set shapeContent to content of text range of text frame of thisShape
display alert (shapeTypeText)
end repeat
end tell
end getProperty
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"
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