R
Ram Chepyala
Hi
I am opening a existing workbook using an excel macro and adding a
module with some code and i am using send keys to protect the VBA
project of the opened work book. But unfotunately it adds the password
and protects the excel sheet which has the orginal macro.
below is teh code iam using, can anybody suggest me a different
solutions or modification sto the code
Sub ProtectVBProject(WB As Workbook, ByVal Password As String)
Dim vbProj As Object
Set vbProj = WB.VBProject
'can't do it if already locked!
If vbProj.Protection = 1 Then Exit Sub
Set Application.VBE.ActiveVBProject = vbProj
SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" & _
Password & "~"
Application.VBE.CommandBars(1).FindControl(Id:=2578,
recursive:=True).Execute
WB.Save
End Sub
Many thanks in advance
Regards
Ram
I am opening a existing workbook using an excel macro and adding a
module with some code and i am using send keys to protect the VBA
project of the opened work book. But unfotunately it adds the password
and protects the excel sheet which has the orginal macro.
below is teh code iam using, can anybody suggest me a different
solutions or modification sto the code
Sub ProtectVBProject(WB As Workbook, ByVal Password As String)
Dim vbProj As Object
Set vbProj = WB.VBProject
'can't do it if already locked!
If vbProj.Protection = 1 Then Exit Sub
Set Application.VBE.ActiveVBProject = vbProj
SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" & _
Password & "~"
Application.VBE.CommandBars(1).FindControl(Id:=2578,
recursive:=True).Execute
WB.Save
End Sub
Many thanks in advance
Regards
Ram