The issue is simple in this case: The >Tools>Macros>Run proceeding (I virtually never use it.) checks for an applicaple set of parameters before it actually starts the Sub. Since the routine never actually passes a parameter, it expects Sub either without any parameter or with all the parameters declared 'Optional'. I obviously had removed that keyword inadvertently.
On the other hand a call to a Sub due to a button event or from an object contained in a toolbar
always passes an event parameter, and the called Sub must be prepared to accept it - whether it evaluates it or not. (I told already.)
Anyway: You need to take seriously what Zizi64 told. If you actually want to continue on the way you started, you should be prepared to have to read a lot, and to spend
very many hours. And you should be prepared to experience that you will fail with some projects again and again nonetheless. For most users not much interested in programming and internals of software this will be wasted time. There are a few things they can do based on recorded macros - and that is it. To rework a recorded macro slightly to better adapt it to an intended use case may also work sometimes for the expense of hard thinking. To know about the 'Optional' thing may be useful then.
Another question: Why? I cannot think of a real use case where the toggling sheet protection via a button click is of much use. You would need to have a copy of that button on every sheet. And concerning "your other question" that's even more an important issue.
(I personally never hide headers. What good for? It's MS thinking at best, imo.)
Finally I attach a demo covering both your recent questions (also
viewtopic.php?f=9&t=100555) and containing a custom toolbar saved with the document. Concerning your questions this way to call the Sub should be preferrable.
(This should not be continued in the same style. You have to make a decision, and you will find partners for one or another discussion here, but not private teachers spending a few hours to teach you every other day.)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München