![]() |
Protect Excel VBA Project from another Excel Macro
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:=257 8, recursive:=True).Execute WB.Save End Sub Many thanks in advance Regards Ram |
All times are GMT +1. The time now is 05:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com