This code may help you out;Option Explicit
Const BreakIt As String = "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}"
Sub Change_VBA_PW()
Dim WB As Workbook
Dim Password As String
Set WB = ActiveWorkbook 'Or your workbook name
Password = "test"
Call SetVBProjectPassword(WB, Password)
End Sub
Sub SetVBProjectPassword(WB As Workbook, ByVal Password As String)
'Needs reference to Visual Basic for Applications Extensibility Library
Dim VBP As VBProject
Dim OpenWin As VBIDE.Window
Dim i As Integer
Set VBP = WB.VBProject
Application.ScreenUpdating = False
' close any code windows to ensure we hit the right project
For Each OpenWin In VBP.VBE.Windows
If InStr(OpenWin.Caption, "(") > 0 Then OpenWin.Close
Next OpenWin
WB.Activate
'Application.OnKey "%{F11}"
SendKeys BreakIt & Password & "{tab}" & Password & "~" & "%{F11}", True
Application.ScreenUpdating = True
WB.Activate
End Sub
HTH
Ivan