Powerpoint Changing Slide at Specific Time - vba

I was wondering if there is a script that I can add to my powerpoint presentation to allow it to change to a specific slide at a given computer time.
For example I would like the powerpoint to loop through some slides and then at 10am I would like it to go to a slide that is hidden from the loop and stay at that slide. I was wondering if that could be done? If possible that would be amazing and I would love it if it could :)

See this link: social.msdn.microsoft.com/forums/en-US/… to create a timer for PowerPoint.
Then put code in to check the current time vs the time you want to go to the slide and then if the time has reached this time, go to that slide.

Related

Creating a PPT macro to send slide to section based on day/time

First time poster here! I am hoping someone can help me find a way to create a macro that would direct the powerpoint to advance to a certain section depending on the day/time. I have four sections (weekdayAM, weekdayPM, weekendAM, weekendPM) and a single slide at the start of the presentation with a textbox start button. Ideally, I would like to enable an onclick macro to direct to the appropriate section based on the day/time conditions.
Any ideas?

VBA for Powerpoint: Change Slide in One Powerpoint by Selecting Button in Another

I am a beginner at VBA.
I am designing a somewhat interactive Powerpoint presentation/s. I want to be able to have three separate Powerpoint presentations open that will link together. I have been trying (without success) to create, in VBA, code which will change the current displayed slide on one Powerpoint file by clicking a button in another. I can hyperlink to the set slide but this causes this slide to pop up on the same screen in which it is clicked, despite it being already open in another screen (I don't want this).
Thanks in advance for any help,
Holly
VBA uses an object model that is a huge hierarchy of attributes and functions that represent the application. You can use this model to view and update attributes to get text, resize, and modify the application. You should look at some tutorials to get you started. When editing your code, you can press F2 to see and explore this object model. You can press F8 to run your code line by line (debug mode) and see what is happening.
To your question, you can access the open presentations in the application.presentations object (https://learn.microsoft.com/en-us/office/vba/api/powerpoint.presentations). You could then use a presentation in that list and use the ActiveWindow.View.goToSlide function (https://learn.microsoft.com/en-us/office/vba/api/powerpoint.view.gotoslide). Here is a free tutorial that I've used in my VBA journey (https://www.tutorialspoint.com/vba/index.htm).
PowerPoint has a Presentations collection that contains all currently open presentations. You can get a reference to any of them via Presentations("name") where "name" is the filename of the presentation, sans extension.
So ... assuming you've got three presentations open, a.pptx, b.pptx, c.pptx you can do something like this:
Sub SlideChange()
With Presentations("c")
.SlideShowWindow.View.GotoSlide (3)
End With
End Sub
If you run the above in any of the presentations, it will change the slide show window displaying presentation c to the third slide.

How do you set the trim setting for a video in PowerPoint using VBA?

I have the same video positioned on multiple slides, but instead of starting from the beginning at each slide, I want it to commence playback from where the previous slide ended.
My idea for approaching this is to have a macro that automatically starts at the beginning of the presentation and just records the time somewhere. Then, upon slide transition, check the time again and determine where the video should be trimmed to on the new slide. The problem is that I can't find any way to set the trim/seek point using VBA. Is there any way to do this?
For anyone else with a similar issue, I did find a solution.
ActivePresentation.Slides("your slide").Shapes("your shape").MediaFormat.StartPoint = yourStartPoint

How to stop PowerPoint 2013 crash when copying slides either in VBA or with CTRL+C

So I have a fairly complex PowerPoint I've been working on--it is a complex training program combined with a testing portion that presents multiple choice questions some of which are just text, some of which are graphical, some of which are animated graphics, and some of which are synthesized speech and audio, etc. When the user answers a slide incorrectly, VBA code copies the slide to the end of the presentation so that the user must answer missed questions again to ensure learning the correct response.
Anyway, I had added about 200 slides and then I ran into a problem. After running a certain slide, the VBA code that copied the slide started causing an error of "invalid function" for the simple line of code: oSld.Copy. I then tried manually copying the slide by using CTRL+C in the slide editing window and I got a similar error but worded differently; something like this: "We're sorry, something went wrong that might make PowerPoint unstable. Please save your presentation and restart PowerPoint."
I was completely baffled by this odd behavior and thought perhaps the PowerPoint was balking at the number of slides, so, I reduced the number of slides to only 15 or so, but, the same slide still caused problems at oSld.Copy and CTRL+C.
I spent hours trying to narrow down where the error was occurring and it seemed consistently linked to this one slide for the longest time. But then, I happened to get the same error on another slide. The commonality was that they both had unusual animations on the slides. Specifically, on both slides, I had a group of shapes and the group was animated with the "Lines" animation that moved the group of shapes from one point to another point.
When I deleted the animations from those slides, there was no longer an error for oSld.Copy nor when using CTRL+C.
My workaround (which to this point in time has worked) was that I added code to delete the animations from the source slide after copying the source slide to the end of the presentation. Fortunately, the error with the copying seems only to occur when trying to copy a second slide with a complex animation, not after copying the first slide with a complex animation. Thus, by deleting the complex animation after copying the slide, the animation was correctly copied to the slide at the end of the presentation, but apparently deleting the animation from the source slide prevented problems when copying the next complex animation slide.
I modified code by John Wilson of PowerPoint Alchemy to delete the animations as follows:
Sub DeleteAnimations()
Dim i As Integer
Dim t As Integer
Dim osld As Slide
'delete anims from just the current slide
Set osld = ActivePresentation.Slides(ActivePresentation.SlideShowWindow.View.CurrentShowPosition)
'Remove normal animations
For i = osld.TimeLine.MainSequence.Count To 1 Step -1
osld.TimeLine.MainSequence(i).Delete
Next i
'Remove triggers
For i = osld.TimeLine.InteractiveSequences.Count To 1 Step -1
For t = osld.TimeLine.InteractiveSequences(i).Count To 1 Step -1
osld.TimeLine.InteractiveSequences(i).Item(t).Delete
Next t
Next i
End Sub
I was pulling my hair out trying to get rid of the error and since it took me so long to figure it out, I hope that posting this information here will help out some other individual.

maintaining image object visibility with vba

i am developing a large non-linear powerpoint which has many sub sections to it. This has necessitated a table of contents slide (TOC). in this slide i am representing each section with its own picture. also on the slide are 2 buttons which let the user switch between images. The buttons do this by setting the appropriate section image to visible and all the others to invisible, so that only one sections image is visible at a time. my goal is to make sure that whenever the user goes back to the table of contents slide that the slide displays the same section image each time, regardless of which section what entered the previous time, i.e. the image for section 1 should be visible whenever the user goes back to the table of contents. how do i go about doing this?
also, if i can find new sources to learn more about syntax and other vba coding, i would be most appreciative.
i already consult:
pptalchemy.co.uk
skp.mvps.org
msdn.microsoft.com
i just cannot find more good sites that will help.
I don't quite understand the situation, but one possibility:
Add another slide before the TOC. You could make it a duplicate of the TOC slide (with the image you want in place).
Instead of linking back to the "real" TOC slide, link to this one instead.
On this slide, add a rectangle that covers the entire slide, make it 99% transparent and give it a Run Macro mouse over action setting.
Have the macro do nothing more than set the image you want on slide 2 to be visible, then jump to slide 2 (the real TOC slide), eg
SlideShowWindows(1).View.GoToSlide(2)
The mouse over macro will trigger as soon as the user moves the mouse, and since that will trigger a jump from one slide to an identical one, it will be invisible to the user.
most of the solution came from [pptalchemy] (http://www.pptalchemy.co.uk/PowerPoint_Auto_Open_Code.html):
I downloaded the custom ui editor for microsoft office
I added the code from ppt alchemy to the custom ui editor for the slide show.
In vba i added the code:
Sub onloadcode()
Debug.Print "Running"
End Sub
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = SSW.Presentation.Slides("TOC").SlideIndex Then
'code here'
end if
end sub
the code executes perfectly now, and i have condensed my table of contents from 9 slides down to 1. Just, don't add features to the code until you have everything in place to accept them. In my case i added the code for text boxes which did not exist yet and that messed up my code a lot. Once i made all of the objects for the code and then added the code it worked perfectly.