steven-v-hanson
asked on
I want a clean way of stopping my looping powerpoint presentation
VBA ms powerpoint and ms access.
I am running a powerpoint slideshow continuously from ms access. I have two questions:
1. if my powerpoint slides have an action button, is the button active while the slide is presenting?
2. if the button IS active and I click it, will I be able to detect in from the ms access application? If so, how do I detect it from access?
MY PROBLEM IS: I want to have a clean way to stop the looping presentation.
I am running a powerpoint slideshow continuously from ms access. I have two questions:
1. if my powerpoint slides have an action button, is the button active while the slide is presenting?
2. if the button IS active and I click it, will I be able to detect in from the ms access application? If so, how do I detect it from access?
MY PROBLEM IS: I want to have a clean way to stop the looping presentation.
ASKER
Thanks, Jamie. The slides in the presentation are loaded into a collection in ms access and then they are displayed in an unbound object on an access form. I think the connection to ppt has been closed just after the collection is loaded. So I guess your suggestion would work if that connection was still open and the click event got picked up in the ppt event module. But even in that case, the access presentation would still be running. How would I interrupt it or set some global in the access vba? If I could do that, each time through a slide, I could check to see if the global value was set to something.
Hi Steven. Do you have any code snippet you can share, particularly relating to the part "displayed in an unbound object on an access form" as I'm not sure what that means? If they slides are being displayed, then that must mean the PowerPoint object instance is loaded in memory and hence event trapping should be possible. For global access to a flag, you could use the SaveSetting and GetSetting methods to pass data between the two apps.
ASKER
Hi Jamie. Not really any code related to the unbound object frame. Just code for dealing with the buttons on the access form which appear to the left of the unbound object frame. I recorded audio files for each of my slides and when I run the slide show I just start at the first slide in the collection and play the associated audio file using the sync option so that the code pauses while the audio file plays. When the audio file finishes, the code resumes, I bump up to the next slide and play its related audio file. I was using the buttons to advance the slide show but I'm going to change that to automatically bump to the next slide when the audio file finishes. I will enable the buttons between slides and leave them enabled for 5 seconds using a delay timer and this will allow me to interrupt the show between the slides. I labeled my audio files "Slide_1_audio.wav", "Slide_2_audio.wave", etc. The slides play in the unbound frame because I inserted my pptx application into it. I'm going to give you credit for the solution because of the information you shared about the interrupt being picked up in the instance. Thanks.
ASKER
Hi again, Jamie.
Here's the code snippet you asked for.
a button on the access form loads the ppt slides to the collection.
Here's how the pptx is placed into the unbound frame.
Private Sub insertShow_Click()
On Error GoTo insertShow_Click_Error
' Open PowerPoint
Dim strPowerPointFile As String
Dim pptobj As PowerPoint.Application
Set pptobj = New PowerPoint.Application
pptobj.Visible = True
pptobj.WindowState = ppWindowMinimized
strPowerPointFile = CurrentProject.Path & "\yourpowerpoint.pptx"
' Fill a collection with all Slide IDs.
With pptobj.Presentations.Open( strPowerPo intFile)
Set mcolSlideIDs = New Collection
Dim ppSlide As PowerPoint.Slide
For Each ppSlide In .Slides
mcolSlideIDs.Add ppSlide.SlideID
Next
.Close
End With
' Close PowerPoint
pptobj.Quit
Set pptobj = Nothing
Here's the code snippet you asked for.
a button on the access form loads the ppt slides to the collection.
Here's how the pptx is placed into the unbound frame.
Private Sub insertShow_Click()
On Error GoTo insertShow_Click_Error
' Open PowerPoint
Dim strPowerPointFile As String
Dim pptobj As PowerPoint.Application
Set pptobj = New PowerPoint.Application
pptobj.Visible = True
pptobj.WindowState = ppWindowMinimized
strPowerPointFile = CurrentProject.Path & "\yourpowerpoint.pptx"
' Fill a collection with all Slide IDs.
With pptobj.Presentations.Open(
Set mcolSlideIDs = New Collection
Dim ppSlide As PowerPoint.Slide
For Each ppSlide In .Slides
mcolSlideIDs.Add ppSlide.SlideID
Next
.Close
End With
' Close PowerPoint
pptobj.Quit
Set pptobj = Nothing
ASKER
Here's the code to actually use the unbound object frame.
' Make object frame visible and enable "navigation" buttons.
pptFrame.Visible = True
frstSlide.Enabled = True
lastSlide.Enabled = True
nextSlide.Enabled = True
nextSlide.SetFocus
insertShow.Enabled = False
insertShow.Visible = False
previousSlide.Enabled = True
cmdStop.Visible = True
cmdStop.Enabled = True
' Specify OLE Class, Type, SourceDoc, SourceItem and other properties.
With pptFrame
.Class = "Microsoft Powerpoint Slide"
.OLETypeAllowed = acOLELinked
.SourceDoc = strPowerPointFile
End With
SetSlide 1
frstSlide.SetFocus
insertShow.Enabled = False
Exit Sub
insertShow_Click_Error:
MsgBox Err.Number & " " & Err.Description
Exit Sub
End Sub
' Make object frame visible and enable "navigation" buttons.
pptFrame.Visible = True
frstSlide.Enabled = True
lastSlide.Enabled = True
nextSlide.Enabled = True
nextSlide.SetFocus
insertShow.Enabled = False
insertShow.Visible = False
previousSlide.Enabled = True
cmdStop.Visible = True
cmdStop.Enabled = True
' Specify OLE Class, Type, SourceDoc, SourceItem and other properties.
With pptFrame
.Class = "Microsoft Powerpoint Slide"
.OLETypeAllowed = acOLELinked
.SourceDoc = strPowerPointFile
End With
SetSlide 1
frstSlide.SetFocus
insertShow.Enabled = False
Exit Sub
insertShow_Click_Error:
MsgBox Err.Number & " " & Err.Description
Exit Sub
End Sub
I guess you just need to have a boolean variable that stops the adding of the slides...and closing the powerpoint...if you could post a small sample maybe we could help more.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I put in a delay of 2 seconds between slides which let me click an exit button
2. You can assign a VBA macro to any button or non-active control shape on a slide and within that macro event you could inform Access that the slide show has ended.