View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] crookie74@hotmail.com is offline
external usenet poster
 
Posts: 4
Default Setting VBA passwords from within code

I have found that it doesn't seem to be easy to set a VBA password
easily from within code. I figure that I probably have to go down the
send keys route and so have set up the following sub

Sub SetVBAPassword()
Dim strPassword As String
strPassword = "monkey"

Excel.SendKeys "%TE^{TAB}VP", False
Excel.SendKeys strPassword & "{TAB}" & strPassword, False
Excel.SendKeys "{Enter}", False
End Sub

My problem is that this code will only work if it is in the same
project as the one you want to set the password for. I want to be able
to set the password from another workbook but don't know how to do it.
Can someone please help me.