# VBA Remove Password on Word Documents



## unknownymous (Jul 10, 2019)

Hi Guys,

I'm using below codes to remove password and save excel files without password. Can you help me modify the codes so I can use this for word files?

===================

Sub RemovePassword()


Dim xlBook As Workbook
Dim strFilename As String
Const fPath As String = "C:\My Folder"        'The folder to process, must end with ""
Const strPassword As String = "mypassword1"        'password use
Const strEditPassword As String = "mypassword1" 'password use
    strFilename = Dir$(fPath & "*.doc") 'will open xls & xlsx etc
    While Len(strFilename) <> 0
        Application.DisplayAlerts = False
        Set xlBook = Workbooks.Open(FileName:=fPath & strFilename, _
                                    Password:=strPassword, _
                                    WriteResPassword:=strEditPassword)
        xlBook.SaveAs FileName:=fPath & strFilename, _
                      Password:="", _
                      WriteResPassword:="", _
                      CreateBackup:=True
        xlBook.Close 0
        Application.DisplayAlerts = True
        strFilename = Dir$()
    Wend


End Sub

===============

Thanks a lot for your help.


----------

