Cliff_Chism
New Member
- Joined
- Jul 13, 2021
- Messages
- 4
- Office Version
- 2013
- Platform
- Windows
Hello everyone, I need help. I have 2,470 excel files in 1 folder. They all have only 1 page/tab in each file and all have the same password "oil". I need to unprotect them all. I have a VBA code that I found online to run but it isn't working properly, it "runs" 639 but it doesn't unprotect them. I am not sure what it is doing but it is running and it creates a backup which I really don't need a back of. I have to compile data from 5 years by copying from each PO to enter into another file to have a sheet to be able to filter. This will save me an incredible amount of time when adding up over 2,400 files to unprotect. Below is the code that isn't working. This is the 1st time I have ever tried to use and run VBA. I greatly appreciate any and all help, direction and advice. Thank you in advance
Sub RemovePasswords()
Dim xlBook As Workbook
Dim strFilename As String
Const fPath As String = "C:\Users\BlackBay OA\Desktop\Past PO 2013-2017\" 'The folder to process, must end with "\"
Const strPassword As String = "oil" 'case sensitive
Const strEditPassword As String = """" 'If no password use""
strFilename = Dir$(fPath & "*.xls") '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
Sub RemovePasswords()
Dim xlBook As Workbook
Dim strFilename As String
Const fPath As String = "C:\Users\BlackBay OA\Desktop\Past PO 2013-2017\" 'The folder to process, must end with "\"
Const strPassword As String = "oil" 'case sensitive
Const strEditPassword As String = """" 'If no password use""
strFilename = Dir$(fPath & "*.xls") '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