Disable Form button

BMD44

Board Regular
Joined
Sep 25, 2019
Messages
72
I have included Button from 'Form controls' in Excel.

Now, I want the button to be disabled when I open the workbook.

I used below syntax, but it doesn't disable the button.

ActiveSheet.Shapes("Button 1").ControlFormat.Enabled = False

The same syntax works for Command button

ActiveSheet.Shapes("CommandButton1").ControlFormat.Enabled = False

Can any one please help how can we disable Form Controls - Button.

Thanks in advance
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
.
Your syntax is correct ... it works here.

Paste a UserForm button on the Worksheet and use your syntax :

ActiveSheet.Shapes("Button 1").ControlFormat.Enabled = False


An ActiveX button on the sheet would be :

Sheets("Sheet1").CommandButton1.Enabled = False
 
Upvote 0
Hello,

I tried the same. It doesn't work for me. I can see the message displayed, but do not see the disable functionality working.

Sub Button7_Click()
ActiveSheet.Shapes("Button 8").ControlFormat.Enabled = False
MsgBox "This is button7"
End Sub

Sub Button8_Click()
ActiveSheet.Shapes("Button 7").ControlFormat.Enabled = False
MsgBox "This is button8"
End Sub

Please let me know if I am missing anything.
 

Attachments

  • Form Buttons.png
    Form Buttons.png
    7.3 KB · Views: 4
Upvote 0
I have found that disabling form control buttons, stopped working some years ago.
How about hiding the button instead?
 
Upvote 0
Thank you for the immediate reply. The requirement I have is to disable the button.

So, I am trying to figure out if we have a work around.
 
Upvote 0
It is the 4th post in the thread & is indicated at the right hand side of each post.
1596134643273.png


The suggestion I made as a workaround was to hide the button.
 
Upvote 0
.
Here is an edit to the existing macro that changes the Button Caption from "Enabled" to "Disabled" .

VBA Code:
Sub UserFrmButnNO()
    ActiveSheet.Shapes("Button 1").ControlFormat.Enabled = False
    Worksheets("sheet1").Shapes("Button 1").Select
    Selection.Characters.Text = "Disabled"
    
End Sub

Sub UserFrmButnYES()
    ActiveSheet.Shapes("Button 1").ControlFormat.Enabled = True
    Worksheets("sheet1").Shapes("Button 1").Select
    Selection.Characters.Text = "Enabled"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top