How to provide VBA access for a modify password protected read only PowerPoint file?

和自甴很熟 提交于 2019-12-13 06:20:56

问题


I’m trying to create a free non-editable version of a PowerPoint slide that demonstrates how VBA can be used to make a slide very dynamic. The slide is an interactive stopwatch and there is a video of it here:

http://i-present.co.uk/free-stuff/free-powerpoint-stopwatch/

VBA is used to modify various shapes on the slide based on the Windows API timer.

In the free version, I want the VBA functionality to run but set the presentation up so that the slide objects cannot be edited.

This is what I’ve tried so far:

1 - Setting a modify password on a ppsm version of the file. Problem : VBA cannot modify the properties of objects on the slide when the presentation is opened in read only mode.

2 - Using VBA to save a temporary write version of the file. Problem : once the presentation is opened as read only, it doesn’t appear to be possible to use VBA to provide the password and then save as a modifiable file.

3 - Creating a separate ppsm file which has a single shape on it, with an Action to run a macro to open the password protected stopwatch deck. Problem : the VBA code to open a password protected presentation (available since PowerPoint 2010) causes PowerPoint 2013 to crash:

Dim oPVW As ProtectedViewWindow
Dim oPres As Presentation
Set oPVW = ProtectedViewWindows.Open(FileName, ReadPassword)
Set oPres = PVW.Edit(ModifyPassword)

4 - Embedded the stopwatch ppsm file within another presentation as a slide object so that the user can click on it but not save and edit it. Problem : spawning a slide show from an embedded object causes the VBA code to not run.

Doe anyone have any ideas how the need can be addressed?


回答1:


Well howdy, Mr.ChromeBumpers

One approach:

Let them edit the shape to their heart's content. But warn them that if they do, your code will decline to run.

Your code can test any combination of the shape's properties you like: Height, width, top, left, color, text and so on. And refuse to run if even one of those properties has been altered from the shape as supplied by you.




回答2:


Here is code in Excel that opens a password protected PowerPoint file. Replace the password with your actual password. This has worked in 2010, 2016 and 365 office.

Dim PPTObj As Object
Set PPTObj = CreateObject("PowerPoint.application")
PPTObj.Presentations.Open ("C:\PowerPoint\PW_prot_file.pptm:password::")


来源:https://stackoverflow.com/questions/21827650/how-to-provide-vba-access-for-a-modify-password-protected-read-only-powerpoint-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!