![](/img/trans.png)
[英]How to get the handler of an opened powerpoint presentation in Excel VBA
[英]VBA code to unprotect a opened powerpoint presentation, then protect it again before saving it?
我保護了PowerPoint演示文稿,防止用戶對其進行修改。 但是我不能使用VBA對其進行保護。
我嘗試在下面使用此代碼,但是它不起作用。 它僅適用於不受保護的演示。 但是您將必須從代碼中刪除密碼。
set p = pa.presentations.open(pth + pptname, pw)
假設您知道密碼,則可以使用以下方式打開文件:
Presentations.Open("c:\temp\protected_presentation.pptx::password::")
並在演示文稿上設置密碼,例如:
ActivePresentation.Password = "Hide_me"
[編輯以添加一個完整的經過測試的有效示例,該示例假定演示文稿C:\\ temp \\ testtest.pptx已經使用密碼opensesame保存了]
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.