Open file dialog without interrupting slideshow?

All discussions including technical help related to Visual Basic for Applications (VBA) in PowerPoint should be posted under this forum.

Open file dialog without interrupting slideshow?

Chronocidal Guy
Joined: 26 Apr 2012, 22:53

26 Apr 2012, 23:16 #1

So, the simple version of what I'm doing: I'm making a media player in PowerPoint.

What it really is, is a viewer that will show multiple videos at once using the Windows Media Player object, and let you pause/play/stop them all at once. It's basically a jury-rigged workaround to address the fact that our work network won't allow any of the obvious software solutions, and we need something fast that lets us compare a couple video files simultaneously.

So far, I can make a nice slide covered in media player windows, I can play/pause/stop etc them all at once, and I can even use a slider control to move to a specific time.

But I can't load files into the media player windows, at least, not without exiting the slideshow.

I've tried several ways around this. The problem is that your standard application.FileDialog code references Powerpoint itself, and not the WMP window, so using that code minimizes the slideshow, and thinks you want to open a new PowerPoint presentation. It'll correctly load the file into the WMP object, but you have to manually alt-tab back to it.

I thought I'd found a solution using the SelectFile Class from the "More Controls" listing, but I don't think it's properly supported in PPT2007, and while I can get it to work, trying to open the slideshow on another computer gives me a warning that the slide contents have been corrupted, and deletes everything.

What I really need is a way to open a file browse dialog window that directly refers to the WMP objects. So far, I haven't found any type of method that will let you browse to a file without minimizing the slideshow.

Are there any workarounds to do this? Preferably without requiring hundreds of lines of code.. the project is on a standalone network, and I'd have to retype any code I see directly into the project.

PowerPoint Elite
PowerPoint Elite
Joined: 17 Dec 2008, 16:05

27 Apr 2012, 07:20 #2

Does this work?

Code: Select all

Sub getfile()
Dim fd As FileDialog
Dim sFilename As String
Dim osld As Slide
Set osld = SlideShowWindows(1).View.Slide
Application.WindowState = ppWindowMinimized
Set fd = Application.FileDialog(msoFileDialogFilePicker)
        With fd
            .InitialFileName = Environ("USERPROFILE") & "\Videos\"
            .InitialView = msoFileDialogViewList
            .AllowMultiSelect = False
            .Title = "PowerPoint Alchemy - Please browse for your movie file"
            .Filters.Add "Movie files", "*.wmv"
            If .Show = -1 Then
                sFilename = .SelectedItems(1)
            End If
        End With

        If sFilename = "" Then Exit Sub
'feed filename into media player
        osld.Shapes("WindowsMediaPlayer1").OLEFormat.Object.URL = sFilename
        Set fd = Nothing
End Sub

Sub OnSlideShowTerminate()
Application.WindowState = ppWindowMaximized
End Sub