ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   simple question "disable command buttons" (https://www.excelbanter.com/excel-programming/374812-simple-question-disable-command-buttons.html)

eighthman11

simple question "disable command buttons"
 
Quick simple question. I want to disable a command button when my
excel spreadsheet is opened. I've tried the following code. It does
not work.

Private Sub Workbook_Open()

ActiveSheet.Buttons("CommandButton1").Enabled = False
ActiveSheet.Buttons("CommandButton2").Enabled = False


End Sub

any help appreciated.


Ron de Bruin

simple question "disable command buttons"
 
Use this if you are sure that the controltool box button is on the active sheet when you open the workbook

ActiveSheet.OLEObjects("CommandButton1").Enabled = False



--
Regards Ron de Bruin
http://www.rondebruin.nl



"eighthman11" wrote in message ups.com...
Quick simple question. I want to disable a command button when my
excel spreadsheet is opened. I've tried the following code. It does
not work.

Private Sub Workbook_Open()

ActiveSheet.Buttons("CommandButton1").Enabled = False
ActiveSheet.Buttons("CommandButton2").Enabled = False


End Sub

any help appreciated.





All times are GMT +1. The time now is 01:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com