我在Excel中使用下面的宏打开受密码保护的Word文档,然后我想保存没有密码保护的文档副本。目前,当我尝试打开新保存的文档时,仍然会提示我输入原始密码。
Dim DPObj
Dim DPApp As Object
Dim YourOwnPassword As String
Dim DocPath As String
DocSrcPath = "C:\Users\ADMIN\Desktop\Sources\SourceDoc.doc"
DocTgtPath = "C:\Users\ADMIN\Desktop\Targets\TargetDoc.doc"
YourOwnPassword = "TestPWD"
Set DPApp = CreateObject("word.Application")
'Open Password enabled document
DPDoc = DPApp.Documents.Open(DocSrcPath, PasswordDocument:=YourOwnPassword)
'Make some changes to the document.
'Save the edited document without a password
DPApp.ActiveDocument.SaveAs2 DocTgtPath
有人知道怎么做才能让TargetDoc.doc
仍受密码保护吗?
答案 0 :(得分:2)
使用空白密码应该有效:
DPApp.ActiveDocument.SaveAs2 DocTgtPath, Password:=""