Place this code in the Password File...Assumes all files have passwords allocated...
Sub J3v16()
Dim File As Object, Path As String, S1 As String, S2 As String, Pw As String
Dim ws As Worksheet, Sht As Worksheet: Set Sht = ActiveSheet
Path = "D:\Steven\Desktop\Files\" '! Change to your path that houses the files...
With CreateObject("Scripting.FileSystemObject")
For Each File In .GetFolder(Path).Files
S1 = .GetBaseName(File.Name): S2 = Split(S1, "_")(1)
Pw = Application.VLookup(S2, Sht.Range("A:B"), 2, 0)
With Workbooks.Open(File, , , , Pw)
For Each ws In .Sheets
ws.Unprotect "abcd123"
Next ws
.SaveAs Path & S1, 51
.Close False
End With
Next File
End With
End Sub
Bookmarks