I am opening a password protected Word document using the below macro in Excel, then I want to save a copy of the document without the password protection. Currently, I am still prompted for the original password when I try and open the newly saved document.
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
Does anybody know how to make it so that the TargetDoc.doc
is not still password protected?
DPApp.Unprotect
before saving. – Vincent GDPApp.ActiveDocument.Unprotect
– Vincent G