I haven't figured out a way to modify the password without opening the file. You can however turn off calculations, screenupdating, etc., during the procedure to improve speed somewhat if the workbook e.g. contains volatile formulas.
As for (2), to pick up the password, replace sPW and/or sNewPW:
c(, 2).Value, or c.offset(,1).value, for the corresponding value in column C
c(, 3).Value for the corresponding value in column D
note that the reference in column B, c = c(1,1)
Sub test2()
Dim c As Range, rng As Range
Dim sFolder As String, sSourceFile As String
Dim sPW As String
Dim wb As Workbook
sFolder = "C:\Temp\" 'folder where the files are
sPW = "ABCD" 'current password
On Error Resume Next
Set rng = ThisWorkbook.Sheets("Sheet1").Columns("B").SpecialCells(2, 2) 'all constant textvalues in column B
On Error GoTo 0
For Each c In rng.Cells
sSourceFile = sFolder & c.Value
If Len(Dir$(sSourceFile)) Then
Set wb = Workbooks.Open(sSourceFile, , , , sPW) 'change sPW to c(, 3).Value for corresponding D column
Application.DisplayAlerts = False
wb.SaveAs sSourceFile, wb.FileFormat, c(, 2).Value 'value from C column
wb.Close False
Application.DisplayAlerts = True
End If
Next c
End Sub
Let me know how that works for you.
Bookmarks