Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
protect / unprotect VBA project by macro | Excel Discussion (Misc queries) | |||
Can project unprotect self? | Excel Programming | |||
protect/unprotect a VBA Project | Excel Programming | |||
protect/unprotect a VBA Project | Excel Programming | |||
Protect\Unprotect VBA project | Excel Programming |