VBA代码取消保护打开的powerpoint演示文稿,然后在保存之前再次保护它? [英] VBA code to unprotect a opened powerpoint presentation, then protect it again before saving it?
本文介绍了VBA代码取消保护打开的powerpoint演示文稿,然后在保存之前再次保护它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我保护了一个 Power Point 演示文稿,防止用户对其进行修改.但是我不能使用 VBA 来取消保护它.
I protected a power point presentation from user modifying it. However I can't use VBA to un-protect it.
我尝试在下面使用此代码,但它不起作用.它仅适用于未受保护的演示.但是您必须从代码中删除密码.
I tried to use this code below but it doesn't work. It only works for unprotected presentation. But you will have to remove the pw from the code.
set p = pa.presentations.open(pth + pptname, pw)
推荐答案
假设您知道密码,您可以使用以下内容打开文件:
Assuming you know the password, you can open the file with something like:
Presentations.Open("c:\temp\protected_presentation.pptx::password::")
并在演示文稿上设置密码,例如:
And set the password on a presentation with eg:
ActivePresentation.Password = "Hide_me"
Sub TestTest()
Dim oPPTApp As Object
Dim oPPTPres As Object
Set oPPTApp = CreateObject("PowerPoint.Application")
If Not oPPTApp Is Nothing Then
Set oPPTPres = oPPTApp.presentations.Open("C:\temp\test.pptx::opensesame::")
MsgBox oPPTPres.slides(1).Shapes(1).TextFrame.TextRange.Text
oPPTPres.Close
oPPTApp.Quit
End If
End Sub
这篇关于VBA代码取消保护打开的powerpoint演示文稿,然后在保存之前再次保护它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文