![]() |
How to Unprotect Project Protection through Macro
Hi All,
I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant |
How to Unprotect Project Protection through Macro
Project protection (set within the VBE environment) is not full proof, but
should not prevent macros running! Are you protecting the sheets / workbook? As in this case macros may not work if they need access to the sheets within the workbook. You cannot unprotect projects using VBA, but you can unprotect sheets / workbooks at the start of your code and then protect them again at the end. Is this your problem? -- Cheers Nigel "Resant" wrote in message ups.com... Hi All, I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant |
How to Unprotect Project Protection through Macro
Hi resant
There's no VB object for this. It is possible, but vulnerable, to use SendKeys and simulate the manual action. See http://tinyurl.com/926n9 HTH. best wishes Harald "Resant" skrev i melding ups.com... Hi All, I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant |
How to Unprotect Project Protection through Macro
The SendKeys to UnProtect Macro is work, but cannot Protect the Macro
again except we must close Excel. When Protect Macro executing, VB Project Properties window show flashly. But the macro unable to protect? What's wrong? Thanks, Resant Harald Staff wrote: Hi resant There's no VB object for this. It is possible, but vulnerable, to use SendKeys and simulate the manual action. See http://tinyurl.com/926n9 HTH. best wishes Harald "Resant" skrev i melding ups.com... Hi All, I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant |
How to Unprotect Project Protection through Macro
Please help me,
Why I cannot protect the Macro again? Actually even when we protect the Macro manually by click Tools, etc. It won't abel to protect the Macro, except restart excel first, rite? Below is the code that I took from forum : Sub ProtectVBProject(WB As Workbook, ByVal strPassword 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 ' now use lovely SendKeys to set the project strPassword SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & strPassword & "{TAB}" & strPassword & "~" 'Application.VBE.CommandBars(1).FindControl(ID:=25 78, recursive:=True).Execute 'WB.Save End Sub Thanks again Resant wrote: The SendKeys to UnProtect Macro is work, but cannot Protect the Macro again except we must close Excel. When Protect Macro executing, VB Project Properties window show flashly. But the macro unable to protect? What's wrong? Thanks, Resant Harald Staff wrote: Hi resant There's no VB object for this. It is possible, but vulnerable, to use SendKeys and simulate the manual action. See http://tinyurl.com/926n9 HTH. best wishes Harald "Resant" skrev i melding ups.com... Hi All, I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant |
How to Unprotect Project Protection through Macro
The workbook has to be closed and reopened to make the project unviewable.
And you don't have to reprotect the project. If you don't remove the protection (different than just unlocking the project), then the project will be protected when you reopen it next time. Resant wrote: Please help me, Why I cannot protect the Macro again? Actually even when we protect the Macro manually by click Tools, etc. It won't abel to protect the Macro, except restart excel first, rite? Below is the code that I took from forum : Sub ProtectVBProject(WB As Workbook, ByVal strPassword 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 ' now use lovely SendKeys to set the project strPassword SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & strPassword & "{TAB}" & strPassword & "~" 'Application.VBE.CommandBars(1).FindControl(ID:=25 78, recursive:=True).Execute 'WB.Save End Sub Thanks again Resant wrote: The SendKeys to UnProtect Macro is work, but cannot Protect the Macro again except we must close Excel. When Protect Macro executing, VB Project Properties window show flashly. But the macro unable to protect? What's wrong? Thanks, Resant Harald Staff wrote: Hi resant There's no VB object for this. It is possible, but vulnerable, to use SendKeys and simulate the manual action. See http://tinyurl.com/926n9 HTH. best wishes Harald "Resant" skrev i melding ups.com... Hi All, I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant -- Dave Peterson |
How to Unprotect Project Protection through Macro
Thanks for your respon
But what you mean by Remove the protection different form Unlock the Project? Could you explain it? Thank you very much Dave Peterson wrote: The workbook has to be closed and reopened to make the project unviewable. And you don't have to reprotect the project. If you don't remove the protection (different than just unlocking the project), then the project will be protected when you reopen it next time. Resant wrote: Please help me, Why I cannot protect the Macro again? Actually even when we protect the Macro manually by click Tools, etc. It won't abel to protect the Macro, except restart excel first, rite? Below is the code that I took from forum : Sub ProtectVBProject(WB As Workbook, ByVal strPassword 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 ' now use lovely SendKeys to set the project strPassword SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & strPassword & "{TAB}" & strPassword & "~" 'Application.VBE.CommandBars(1).FindControl(ID:=25 78, recursive:=True).Execute 'WB.Save End Sub Thanks again Resant wrote: The SendKeys to UnProtect Macro is work, but cannot Protect the Macro again except we must close Excel. When Protect Macro executing, VB Project Properties window show flashly. But the macro unable to protect? What's wrong? Thanks, Resant Harald Staff wrote: Hi resant There's no VB object for this. It is possible, but vulnerable, to use SendKeys and simulate the manual action. See http://tinyurl.com/926n9 HTH. best wishes Harald "Resant" skrev i melding ups.com... Hi All, I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant -- Dave Peterson |
How to Unprotect Project Protection through Macro
If you unlock the project, make your changes, save the workbook, close the
workbook, and then reopen that workbook, you'll see that the project is still protected. Unlocking the project didn't remove the password for next time. This is different than the way worksheet protection works. If you unprotect a worksheet, it'll stay unprotected unless you protect it again. Resant wrote: Thanks for your respon But what you mean by Remove the protection different form Unlock the Project? Could you explain it? Thank you very much Dave Peterson wrote: The workbook has to be closed and reopened to make the project unviewable. And you don't have to reprotect the project. If you don't remove the protection (different than just unlocking the project), then the project will be protected when you reopen it next time. Resant wrote: Please help me, Why I cannot protect the Macro again? Actually even when we protect the Macro manually by click Tools, etc. It won't abel to protect the Macro, except restart excel first, rite? Below is the code that I took from forum : Sub ProtectVBProject(WB As Workbook, ByVal strPassword 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 ' now use lovely SendKeys to set the project strPassword SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & strPassword & "{TAB}" & strPassword & "~" 'Application.VBE.CommandBars(1).FindControl(ID:=25 78, recursive:=True).Execute 'WB.Save End Sub Thanks again Resant wrote: The SendKeys to UnProtect Macro is work, but cannot Protect the Macro again except we must close Excel. When Protect Macro executing, VB Project Properties window show flashly. But the macro unable to protect? What's wrong? Thanks, Resant Harald Staff wrote: Hi resant There's no VB object for this. It is possible, but vulnerable, to use SendKeys and simulate the manual action. See http://tinyurl.com/926n9 HTH. best wishes Harald "Resant" skrev i melding ups.com... Hi All, I've big problem. I've to modify macro code using VBE, and it's done succesfully. But it won't work if I protect the macro with a password. But I have to do that to prevent user change the code. Could I unprotect the Project's Protection through the Macro? Please help me, I really need this Thanks, Resant -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 12:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com