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

Open presentation in Protected View

You can open a presentation programmatically in the Protect View using the ProtectViewWindow object which has an Open method which accepts the name of the presentation to be opened.

Supported versions: PowerPoint 2010


Sub OpenInProtectedView()
Dim oPV As ProtectedViewWindow

Set oPV = Application.ProtectedViewWindows.Open("C:\Users\Shyam\Documents\Presentation2.pptx")
Debug.Print oPV.Caption
Debug.Print oPV.SourceName
Debug.Print oPV.SourcePath

End Sub

What is truly exciting about this method is that for the first time you can programmatically open presentations which have password protection on them. The Open method also has an argument to pass the ReadPassword for the presentation.

 

Sub OpenPasswordProtectedInProtectedView()
Dim oPV As ProtectedViewWindow

Set oPV = Application.ProtectedViewWindows.Open("C:\Users\Shyam\Documents\PassProtected.pptx", "MyPassword" )
Debug.Print oPV.Caption
Debug.Print oPV.SourceName
Debug.Print oPV.SourcePath

End Sub

The ProtectedViewWindow is a distinct object from the ActiveWindow collection. You can enumerate all protected view windows.       

Sub CloseProtectViewWindows()
Dim I As Integer

For I = Application.ProtectedViewWindows.Count To 1 Step -1
Debug.Print "Closing: " & Application.ProtectedViewWindows(I).Presentation.FullName
Application.ProtectedViewWindows(I).Close
Next

End Sub

The ProtectViewWindow object also supports an Edit method which will enable presentation editing. What is also cool is that now you can pass the EditPassword to the method if the Presentation is password enabled.



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