OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

How to display 'Open/Save As' dialogs in PowerPoint
 

The official statement is that dialogs are not supported in PowerPoint object model. However this snippet shows that the dialog exists however the object is hidden. Paste the example into a module and run the OpenDialog routine, this will open the 'Open' dialog of PowerPoint and if when you select a file the dialog reference is passed to the handler 'ProcessSelection'. ProcessSelection merely determines the file that was selected and opens it.

Note: This code is unsupported by Microsoft. This snippet will not function in XP. It is meant specifically for PowerPoint 97/2000 only.


' --------------------------------------------------------------------------------
' Copyright ©1999-2022, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------

Sub OpenDialog()
With Application.FileDialog(ppFileDialogOpen)
' Set file filter flags
    Call .Extensions.Add("*.PPT", "PowerPoint Presentation")
    Call .Extensions.Add("*.PPS", "PowerPoint Show")

    .ActionButtonName = "Open"
    .DefaultDirectoryRegKey = "Default"
    .DialogTitle = "Open"
    .DirectoriesOnly = False
    .InitialView = ppFileDialogViewPreview
    .IsMultiSelect = False
    .IsPrintEnabled = False
    .IsReadOnlyEnabled = True
    .OnAction = "ProcessSelection"
    .UseODMADlgs = False
    .Launch
End With
End Sub

Sub ProcessSelection(ByVal oDlg As FileDialog)
If oDlg.Files.Count = 0 Then Exit Sub
Presentations.Open oDlg.Files(1)
End Sub

 


The official statement is that dialogs are not supported in PowerPoint object model. However this snippet shows that the dialog exists however the object is hidden. Paste the example into a module and run the SaveAsDialog routine, this will open the 'Save As' dialog of PowerPoint and if when you select a file the dialog reference is passed to the handler 'ProcessSelection'. ProcessSelection merely determines the filename that was provided and displayes it in a message box.

Note: This code is unsupported by Microsoft. This snippet will not function in XP. It is meant specifically for PowerPoint 97/2000 only.


' --------------------------------------------------------------------------------
' Copyright ©1999-2022, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------


Sub SaveAsDialog()
With Application.FileDialog(ppFileDialogSave)
    ' Set file filter flags
    Call .Extensions.Add("*.PPT", "PowerPoint Presentation")
    Call .Extensions.Add("*.PPS", "PowerPoint Show")
    .ActionButtonName = "Open"
    .DefaultDirectoryRegKey = "Default"
    .DialogTitle = "Open"
    .DirectoriesOnly = False
    .InitialView = ppFileDialogViewPreview
    .IsMultiSelect = False
    .IsPrintEnabled = False
    .IsReadOnlyEnabled = True
    .OnAction = "ProcessSelection"
    .UseODMADlgs = False
    .Launch
End With
End Sub

Sub ProcessSelection(ByVal oDlg As FileDialog)
If oDlg.Files.Count = 0 Then Exit Sub
MsgBox "Filename provide: " & oDlg.Files(1)
End Sub


 

 

 

Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.