A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
You must use:
Application.Run "ThisWorkbook.UnprotectMacro"
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello everyone,
I have a rather large Excel document that needs to be protected. I wish to unprotect the workbook/sheet during different stages of a macro. Rather than input the "ActiveWorkbook.Unprotect..." code I want to call another Macro which will handle all of it. This way I don't have to replicate everything over and over again.
Simple enough, however - I wish to call the Macro when a UserForm is in use or when a Module Macro is in use. Here's my coding structure:
| ThisWorkbook | Contains the Protect and Unprotect macros that I wish to call |
|---|---|
| UserForm1 | I wish to call the Protect and Unprotect macros stored in the ThisWorkbook section. |
| Module1 | I wish to call the Protect and Unprotect macros stored in the ThisWorkbook section. |
The standard "Call UnprotectMacro" doesn't work for either of them. I also tried "Call ThisWorkbook.UnprotectMacro" and this didn't help either.
Any ideas?
Thanks,
Daniel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
You must use:
Application.Run "ThisWorkbook.UnprotectMacro"
There is an option with the protect method when called with code which allows your code to have access to the worksheet. In VBA help look at the UserInterfaceOnly property to the protect method. So if you protect your sheet with code, then using this option in that command should give your code access to the worksheet and possibly you won't need to protect and unprotect the sheet in your code.
--
Regards,
Tom Ogilvy