Restore an invisible commandbutton on open?

M

Mike Proffit

Hi All. I've got a spreadsheet with a couple of command buttons that launch
vba prcedures. After the user does their stuff, I want a third button that
will hide all three buttons. I've got that part down:

Private Sub Hide_Click()
button1.Visible = False
button2.Visible = False
Hide.Visible = False
End Sub

But I want those three buttons to reappear when the workbook is opened. I've
got an auto-run macro in ThisWorkbook:

Sub Workbook_Open()
button1.Visible = True
button2.Visible = True
Hide.Visible = True
End Sub

On opening the workbook, I get Run-time error '424': Object required.

If I go into design mode, The buttons do appear and I can manually make them
visible again by making their visible property = true. Just want that
automated.

Thanks for any help!
 
G

Guest

You need to be more explicit in your referencing of the buttons. The on open
will be in a general module which by default will act upon the active sheet
(whatever that might be at the time). Try something more like this...

Sub Workbook_Open()
Sheets("Sheet 1").button1.Visible = True
Sheets("Sheet 1").button2.Visible = True
Sheets("Sheet 1").Hide.Visible = True
End Sub
 

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