• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro Error

Dear Hui,


I have designed a small application using VB Form in Excel. I have protected all the Modules, Excel Structure & Excel Workbook to prevent the user to get in to my workings.


I have got some 4 buttons in the front screen to do the job and I am getting the below error message just because I am protecting all the three as mentioned above. Once when I unlock the password for the all the three above, macro functions properly.


I need this very urgently. Can you please tell me how to prevent this error?


Error:


"Cannot run Macro "Test Key File - Encoding.xlsm'!Module1.Button1_Click'. The macro may not be available in this workbook or all macros may be disabled."


I have the enabled Macro settings and went to Trust centre and done what so ever possible. But still I am getting this error.


Is there a way to unprotect the Project module password when excel is open and lock the same once when it is closed? or any other means?


Your help is much appreciated as usual.


Regards,

Ramnath
 
I have many workbooks where I protect the sheets and I protect the project, and I don't need to unprotect it to run macros. I think that is n ot your problem.
 
In your module, at the time of opening the workbook


Type this

[pre]
Code:
ActiveWorkbook.Protect ("Type Your password here")

and once the macro is run, and before saving the said file

type this


ActiveWorkbook.Unprotect ("Type Your password here")
[/pre]
This will help in unlocking the sheet before running macro and protecting the same once the file is closed.

You are getting that error as some one the values that gets changed are locked due to protection.

Hope this helps!


SS
 
Can you post your file somewhere


Check: http://chandoo.org/forums/topic/posting-a-sample-workbook
 
Back
Top