Sub SetWorkbookPassword() Dim myWorkbook As Workbook, pass As String
Set myWorkbook = ThisWorkbook
pass = "Password" If pass = "Password" Then
myWorkbook.Password = pass
Debug.Print "Password set."
Else
Debug.Print "Passwords don't match. No password set." End If End Sub