我需要在 VBA 中打开受密码保护的 word 文档
它要求输入密码,如何通过代码打开
代码:
Dim DPDoc
Dim DPApp
Dim DPPath
DPPath = "C:\MyFolder\PwdProtectdFile.docx"
Set DPApp = CreateObject("word.Application")
' It is asking for the password here
DPDoc = DPApp.Documents.Open(DPPath)
最佳答案
只需添加一个参数:
Dim YourOwnPassword As String
YourOwnPassword = "TestPWD"
DPDoc = DPApp.Documents.Open(DPPath, PasswordDocument:=YourOwnPassword)
来源:https://msdn.microsoft.com/en-en/library/office/ff835182.aspx
关于vba - 在 VBA 中打开受密码保护的 Word 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37550178/