另存为没有密码的密码保护文档 - Excel VBA



>我正在使用Excel中的以下宏打开一个受密码保护的Word文档,然后我想在没有密码保护的情况下保存该文档的副本。目前,当我尝试打开新保存的文档时,系统仍提示我输入原始密码。

Dim DPObj
Dim DPApp As Object
Dim YourOwnPassword As String
Dim DocPath As String
DocSrcPath = "C:UsersADMINDesktopSourcesSourceDoc.doc"
DocTgtPath = "C:UsersADMINDesktopTargetsTargetDoc.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仍然不受密码保护?

使用空白密码应该有效:

DPApp.ActiveDocument.SaveAs2 DocTgtPath, Password:=""

最新更新