make command button invisible

E

Excel-VBA Dummy

Could someone please tell me the syntax to make a command
button visible or invisible?

I was hoping it would be something easy like:

commandbutton.visible = false

but that isn't working.

thanks for any help
 
D

Don Guillett

I just recorded this
Sub Macro7()
'
' Macro7 Macro
' Macro recorded 6/29/2004 by Don Guillett
'

'
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.Shapes("CommandButton1").Select
Range("J15").Select
Application.CommandBars("Control Toolbox").Visible = False
End Sub

Seems like a lot of bother. Why not use a button from forms toolbar or a
shape from drawing. Easier.
Sub hideshape()
ActiveSheet.Shapes("rectangle 4").Visible = False
End Sub
 
K

Ken Macksey

If you use a command button from the "control toolbox " instead of the
"forms toolbar", you can set the visible property.

Commandbutton1.visible = False
or
Commandbutton1.visible = True


HTH

Ken
 
G

Guest

Thank you. This helped alot. I press the command button,
run a macro to make it invisible, copy the current
spreadsheet to another location, and then make the button
visible again.

The only thing that isn't working now - the button doesn't
become visible again, unless I close and re-open the
spreadsheet. Do you know how I can fix this?
 
K

Ken Macksey

Hi

I am not sure exactly what you are trying to do, but try something like

ThisWorkbook.Sheets("sheet1").CommandButton1.Visible = False
ThisWorkbook.Sheets("sheet2").Copy
ThisWorkbook.Activate
ThisWorkbook.Sheets("sheet1").CommandButton1.Visible = True


HTH

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top