Naturally, xld is correct.

Something like this might work for you. The referenced links and comments explain that you need to set a reference to the Visual Basic for Applications Extensibility Library and Trust access to Visual Basic Project (Excel menu, not VBE, Tools > Macro > Security > Trusted Publishers).
[vba]'Posted by Ivan F Moala on September 06, 2001 9:34 PM, http://www.mrexcel.com/archive/VBA/29825.html
'See Chip Pearson's note about trusting VBAProjects, http://www.cpearson.com/excel/vbe.aspx
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
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 are in 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
'SendKeys "enter", True
Application.ScreenUpdating = True
WB.Activate
SendKeys "%{F11}", True
End Sub
[/vba]