Link to home
Start Free TrialLog in
Avatar of isurgyn
isurgyn

asked on

Open and run a powerpoint presentation in Access form

I have a pre-existing powerpoint presentation with inserted video clips.  I am wanting to display the powerpoint in an access form.  The code that I am using does all that perfectly.  However, the embedded video clips don't play in the access form.  Any ideas on how to modify this code to make that work as well.

Option Explicit
Option Compare Database

' Initialize variables.
Private mcolSlideIDs As Collection
Private mlngSlideIndex As Long

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 = "C:\Users\Brian R Will MD\Desktop\Patient Power Point\Patient Education.ppt"
   
    ' Fill a collection with all Slide IDs.
    With pptobj.Presentations.Open(strPowerPointFile)
        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

    ' Make object frame visible and enable "navigation" buttons.
    pptFrame.Visible = True
    frstSlide.Enabled = True
    lastSlide.Enabled = True
    nextSlide.Enabled = True
    previousSlide.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

Private Sub SetSlide(ByVal ID As Integer)
    On Error GoTo ErrorHandler
   
    Select Case ID
    Case Is > mcolSlideIDs.Count
        MsgBox "This is the last slide."
    Case 0
        MsgBox "This is the first slide."
    Case Else
        mlngSlideIndex = ID
        With pptFrame
            .SourceItem = mcolSlideIDs(mlngSlideIndex)
            .Action = acOLECreateLink
        End With
    End Select

    Exit Sub
ErrorHandler:
    MsgBox Err.Number & " " & Err.Description
    Exit Sub
End Sub

Private Sub frstSlide_Click()
    SetSlide 1
End Sub
Private Sub lastSlide_Click()
    SetSlide mcolSlideIDs.Count
End Sub

Private Sub nextSlide_Click()
    SetSlide mlngSlideIndex + 1
End Sub

Private Sub previousSlide_Click()
    SetSlide mlngSlideIndex - 1
End Sub
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

As far as I know, an OLE embedded file, can only be triggered to run from the "Parent" application.

In other words, the video will run in PP, if PP is opened on its own (not opened inside of Access).

If PP is run in (inside) of Access, then the video will only run at the MS Access application level.

I may be wrong, or this may be different in Office 2007, so let's wait for another Export to be sure.

Whats the need to run PP inside of MS Access?
As far as I know, none of the normal Access form controls can play a video.  I believe you have to buy such a control, I was not able to find any that you could download and use for free.  This URL gives you a free limited period use of one that will play AVI files:

http://www.fmsinc.com/microsoftaccess/controls/components/video/avi-player.htm
Avatar of isurgyn
isurgyn

ASKER

Thanks very much for the help.  It is mainly for convenience and an integrated look to display the Powerpoint presentation within the Access form.  I have the code to activate PowerPoint and run the presentation already but just didn't like having to close the PP and resume Access when I am through showing the PPT presentation.

The Access video control looks very interesting.  It would work to show the video clips but would be somewhat cumbersome as I need to display the PPT slides with text as well.  With the text slides and video slides intermixed it would be interesting to format the Access form to toggle back and forth between PPT frame and the ActiveX AVI frame, particularly if I want to show them a close to full screen size.  Also, the price tag on the add-in is enough that the inconvenience of closing PP is probably palatable.

Thanks again.
ASKER CERTIFIED SOLUTION
Avatar of Richard Daneke
Richard Daneke
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
GRayL,

You can use the MS Media player active-x control to play a video in Access.

But I am not sure how it could be "inter-opped" to work from PP...

Jeff
untitled.JPG
Jeff:  Thanks.  I just checked my installed References and there are a wack of Windows Media Player references also.  I've been in this forum for over 8 years and this is the first time I've seen a question where someone wanted to play a video clip in an Access form.  Truth be told this is not my cup of tea - over to you my friend.
Yeah,

I only did this out of curiosity once for another Q.
It worked "OK" but not all WMP features were available, ...and for some reason the control would "shrink" slightly every time you clicked on it...
   ...eventually disappearing into oblivion...


Avatar of isurgyn

ASKER

Great suggestions.  Sometimes the simplest is the easiest.  I changed the code to automate PowerPoint directly and open the presentation and then placed an Action button the triggers a macro in the ppt presentation as per DoDahD's advice.

However, I do like the idea of using the MS Media player and may use that on some pure video features of the database application.

The only issue I have so far with my current code is that it doesn't always seem to open the PowerPoint presentation in a maximized mode.  Any thoughts?

Private Sub cmdOpenPPT_Click()

    Dim ppt As Object
    Dim pptPres As PowerPoint.Presentation
   
    Set ppt = CreateObject("PowerPoint.Application")
    ppt.Visible = True
    ppt.Presentations.Open "C:\Users\Brian R Will MD\Desktop\Patient Power Point\Patient Education.ppt"
   
    ppt.ActivePresentation.SlideShowSettings.Run
   
    Set ppt = Nothing

End Sub


Action button code in PPT slides as follows:

Sub ClosePPT()

    SlideShowWindows(1).View.Exit
    Application.Quit

End Sub

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of isurgyn

ASKER

I will work on the Windows Media Player to see if I can get that solution to work and will post back the code.