Home Products Customers Tips VBA OfficeOne on Mac Contact us

OfficeOne OpenPPT 4.1

Microsoft PowerPoint 2010 introduces a way to open password-protected presentations as follows:

Function OpenPresentationWithPasswords(ByVal FileName As String, _
    ByVal ReadPassword As String, _
    ByVal ModifyPassword As String) As Presentation

    Dim PVW As ProtectedViewWindow

    Set PVW = ProtectedViewWindows.Open(FileName, ReadPassword)
    Set OpenPresentationWithPasswords = PVW.Edit(ModifyPassword)
End Function

The previous versions of Microsoft PowerPoint do not allow you to supply a password through VBA/Automation when opening a password-protected presentation file. Instead, PowerPoint shows the password prompt when Presentation.Open() method is called. This causes the VBA/Automation code to wait until the password prompt is dismissed by the user.

openppt.dll is a small utility that allows you to open password-protected presentations by supplying the password to it.

Download

Download the 333 KB DLL from hereDownload. There is no installation required. You just need to copy the DLL from within the .zip file to the Windows folder for using it.

For PowerPoint x64, there is a 64-bit version of the DLL called openppt64.dll that is available in the Win64 folder in the download. You need to place that in Windows folder if you are using 64-bit version of PowerPoint.

Quote Your Own Price

If you find OpenPPT useful, you can make a contribution here for its maintenance and future releases. On that page, enter the amount that you wish to contribute in the Item price box and make the payment.

Using OpenPPT

You need to place the openppt.dll in the Windows folder (usually, C:\Windows) and ensure that you include the import declarations in your code.

openppt.dll and openppt64.dll export 2 APIs:

Export 1: Function OpenPresentation()

The function can be imported with the following VBA declaration:

Public Declare Function OpenPresentation Lib "openppt.dll" ( _
    ByVal PowerPoint As Variant, _
    ByVal FileName As String, _
    ByVal Password As String, _
    ByVal ReadOnly As Boolean, _
    ByVal Untitled As Boolean, _
    ByVal WithWindow As Boolean) As Variant

This function expects a reference to the PowerPoint Application object, the presentation file name, the password and the other parameters similar to the ones you can specify when calling Application.Presentations.Open() method.

The function returns a reference to the Presentation object. If it is unable to open the presentation file, it returns error in Err object.

You can call this function as follows:

Sub Test()
    Dim Pres As Presentation

    Set Pres = OpenPresentation(Application, _
        "C:\Presentation\MyPPT.ppt", "MyPassword", _
        False, False, True)
End Sub

Export 2: Procedure OpenPresentation2()

The procedure method was introduced to allow openppt.dll to work in .Net. In .Net, PInvoke() does not allow variants to be returned from a function call but it does allow variants to be return by way of reference parameters.

The procedure can be imported with the following VBA declaration:

Public Declare Sub OpenPresentation2 Lib "openppt.dll" ( _
    ByVal PowerPoint As Variant, _
    ByVal FileName As String, _
    ByVal Password As String, _
    ByVal ReadOnly As Boolean, _
    ByVal Untitled As Boolean, _
    ByVal WithWindow As Boolean, _
    ByRef Pres As Variant)

This subroutine expects a reference to the PowerPoint Application object, the presentation file name, the password and the other parameters similar to the ones you can specify when calling Application.Presentations.Open() method. The last parameter returns the presentation object in a variant. Use a variant to receive it and cast it to a Presentation object.

You can call this function as follows:

Sub Test2()
    Dim Pres As Presentation
    Dim PresV As Variant

    OpenPresentation2 Application, _
        "C:\Presentation\MyPPT.ppt", "MyPassword", _
        False, False, True, PresV
    Set Pres = PresV
End Sub

 


Home | Products | Tips | VBA | FAQ | Utilities | Disclaimer | Privacy Policy | Mac | Links | Contact us

Contact OfficeOne on email at officeone@officeoneonline.com. Copyright © 2001-2017 OfficeOne. All rights reserved.

page counter