macro to remove password doesn't work

C

Co

Hi All,

I recorded a macro in Word to remove a password in a word file but it
doesn't work.
The document has a password for editing, however when I open the doc
it asks me to type
the password.

In the macro I open the Options Tab and remove the password then I
close the options window
and save the file. The password is then empty. However when I close
the file and open it again
I still have to type the password and when I look at the Option window
again the password is back.

Is this magic or what?
When I don't use a macro but do everything by hand the password is
gone and it is saved correctly.

Marco
 
T

Tony Jollans

Can you be a little more precise about your actions please?

Perhaps if you post the code you are using it will be easier to help.
 
G

Graham Mayor

The following macro will remove the password(s) from a document
(docname.doc)
If you only have a write password set change

OpenPwd = "password"
to
OpenPwd = ""

Dim OpenPwd As String
Dim WritePwd As String
Dim docName As String
OpenPwd = "password"
WritePwd = "anotherpassword"
docName = "D:\path\docname.doc"

Documents.Open FileName:=docName, _
PasswordDocument:=OpenPwd, _
WritePasswordDocument:=WritePwd
With ActiveDocument
.ReadOnlyRecommended = False
.Password = ""
.WritePassword = ""
End With
ActiveDocument.Close savechanges:=wdSaveChanges


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top