Is there a way to make a **command button** invisible and/or disable it?
Emphasis added.
All I can offer is code that has been tested in the proper context based on
the question asked. (such as in this case).
the button from the forms menu is not a commandbutton. It is simply a
button. If you can't ask the correct question, it would be best not to come
back in an accusatory fashion exlaiming that the code doesn't work.
Buttons from the forms toolbar are members of the buttons collection
Activesheet.Buttons("Button 1").visible = False
they are also members of the Shapes collection, but more than buttons can be
members of this collection. No, they are not members of the OleObjects
collection, but commandbuttons use OleObjects as containers, so if you had
been using a commandbutton as you stated, and the name of the commandbutton
was commandbutton1, or you were able to recognize that you should actually
use the real name of the button, then you would not have had such a problem.
as to useforms, I provided that since you did not state where you were using
the "commandbutton" and I decided to give you as complete an answer as
possible.
here is some code demo's from the immediate window in attempt to assure you
that in the proper context, the recommended code does work:
activesheet.buttons("Button 2").Visible = False
? activesheet.Buttons("button 2").Visible
False
activesheet.buttons("button 2").visible = True
? activesheet.buttons("button 2").visible
True