2

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?

8
  • Why doesn't the current code work? Commented Mar 30, 2017 at 13:18
  • When i open the new document it is prompting for the password "TestPWD". Which i don't wanted to Commented Mar 30, 2017 at 13:22
  • You want to remove the password in the saved document? Try using DPApp.Unprotect before saving. Commented Mar 30, 2017 at 13:23
  • @Vincent G Getting error ** Run-time error '438' Object doesn't support this property or method ** Commented Mar 30, 2017 at 13:30
  • Sorry, I mean DPApp.ActiveDocument.Unprotect Commented Mar 30, 2017 at 13:31

1 Answer 1

3

Using a blank password should work:

DPApp.ActiveDocument.SaveAs2 DocTgtPath, Password:=""
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.